borland Packages Class Hierarchy dx.sql.dataset Package
java.lang.Object +----com.borland.dx.sql.dataset.ConnectionDescriptor
Constructors Properties Methods
Implements Serializable, Cloneable
The ConnectionDescriptor
object stores properties related to connecting to a SQL database. Its main properties are:
connectionURL
(the Universal Resource Locator of the database)
userName
password
driver
properties
Both the ConnectionDescriptor
object and the Database
component are required elements when accessing data that is stored on a SQL server.
The information stored in the ConnectionDescriptor
can be accessed through the user interface by inspecting the connection
property of a Database object. To work with this object programmatically, you set its properties when instantiating the ConnectionDescriptor
, or by its write accessors.
To set these properties through the JBuilder UI design tools, select the Database
object, then double click the area to the right of the connection
property in the Inspector. Or, single click it to display the ellipses button and click it to open the custom property editor dialog for this descriptor. The Connection custom property editor also offers these additional ease-of-use features:
For examples on connecting to a database server, see "Connecting to a database" in the Database Application Developer's Guide.
For application design issues when connecting to a database (including displaying the username/password dialog) see the "Application design" topic in the Database
component.
public ConnectionDescriptor(ConnectionDescriptor cDesc)Constructs a
ConnectionDescriptor
using the property values from the ConnectionDescriptor
object specified as cDesc
.
public ConnectionDescriptor(String connectionURL)Constructs a
ConnectionDescriptor
with the specified URL to the database.
public ConnectionDescriptor(String connectionURL, String userName)Constructs a
ConnectionDescriptor
with the specified connection URL to the database and user name.
public ConnectionDescriptor(String connectionURL, String userName, String password)Constructs a
ConnectionDescriptor
with the specified connection URL to the database, user name, and password.
public ConnectionDescriptor(String connectionURL, String userName, String password, boolean promptPassword)Constructs a
ConnectionDescriptor
with the specified connection URL to the database, user name, password, and whether to prompt for the password each time or store the password in the ConnectionDescriptor
.
public ConnectionDescriptor(String connectionURL, String userName, String password, boolean promptPassword, String driver)Constructs a
ConnectionDescriptor
with the specified connection URL to the database, user name, password, whether to prompt for the password each time or store the password in the ConnectionDescriptor
, and the driver class to use when connecting to the Database
.
public ConnectionDescriptor(String connectionURL, String userName, String password, boolean promptPassword, String driver, Properties properties)Constructs a
ConnectionDescriptor
with the specified connection URL to the database, user name, password, whether to prompt for the password each time or store the password in the ConnectionDescriptor
, the driver class to use when connecting to the Database
, and the instance of a java.util.Properties
that stores extended driver properties to use when connecting.
Not all drivers support connecting to a database using a java.util.Properties
object. Check your driver documentation for more information on whether it supports this feature or not.
public synchronized boolean isComplete()Read-only property that returns true if all the
ConnectionDescriptor
parameters have been set.
public synchronized String getConnectionURL() public synchronized void setConnectionURL(String url)Stores the name of the connection Universal Resource Locator (URL) for the database. The format consists of the URL type ("jdbc" for JDBC database access), followed by driver-specific information, separated by colons. The driver-specific information is driver/server dependent. It typically includes the driver name followed by the data source name. Refer to the documentation for your driver for more information on this property.
To connect to the Local InterBase Server sample file that has been configured with a data source name of DataSet Tutorial
, the URL is: jdbc:odbc:DataSet Tutorial
When you successfully connect to a database, the database URL is saved in the jbuilder.properties file. The URL history is read from the properties file when you click the Choose URL button from the Connection
custom property editor.
public synchronized String getDriver() public synchronized void setDriver(String driver)The driver class to use when connecting to the
Database
, for example, jdbc.odbc.jdbcodbcDriver. This property is optional if you have already registered the driver class with JDBC -- if you specify it, it will not re-register a previously registered class. If the driver class has not been registered with JDBC, specify it here to have DataExpress register the driver class with JDBC, and have JDBC load the driver in memory before attempting the connection to the Database
.
public synchronized String getPassword() public synchronized void setPassword(String password)Stores the password used to connect to the database in the source code as unencrypted text. For maximum security, do not specify the password using this property but set the
promptPassword
property to true.
When accessing this property through the user-interface, an asterisk (*) appears for each character that you type in this field.
public synchronized boolean isPromptPassword() public synchronized void setPromptPassword(boolean prompt)Stores whether the password is maintained in the Java code or not, and therefore, whether the user should be prompted for a password each time a connection to the database is made. The default for this method is false.
When prompted for the password, you can optionally specify an alternate user name for the connection which overrides the userName
property setting at runtime.
For application design issues when connecting to a database and setting this property to true,
see the About section for the Database
component.
public synchronized Properties getProperties() public synchronized void setProperties(Properties properties)Some drivers may require or optionally accept additional connection parameters when connecting to a database. Such drivers take a
java.util.Properties
object that contains the extended properties. Use this property to specify the Properties
object.
java.util.Properties
object. Check your driver documentation for more information on whether it supports this feature or not.
public synchronized String getUserName() public synchronized void setUserName(String userName)Stores the user name used to connect to the database.
public static Properties arrayToProperties(String[][] array)A service method to convert a 2D string array into a
Properties
object.
Used by the ConnectionDescriptor
editor in generating code. Can also be used by developers.
This method returns a Properties
object containing key/value pairs.
array
public String toString()Returns a
String
equivalent of the property values stored in the ConnectionDescriptor
. This String
representation appears in the JBuilder Inspector as the value of the connection
property. The password is not included in the resulting String
.