|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.db.beans.DBConnectionSpec
This bean contains the specifictions for a database connection. You set the properties of this bean before actually connecting to the database. Those properties will determine how the database connection is established (such as using a DataSource or using the DriverManager).
You associate a statement with a DBConnectionSpec via the DBStatement.setConnectionSpec() method. The statement will then use the specification in the DBConnectionSpec to obtain a connection. Setting a statement's DBConnectionSpec is an alternative to setting the connection properties directly on the statement. It is useful if more than one statement will be using the same connection specifications.
The DBConnectionSpec only contains connection properties that cannot be changed after a connection has been obtained. You set connection properties (like autoCommit and transactionIsolation) that can be changed after a connection has been obtained directly on the statement.
If a DataSourceName is specified, a reference to the DataSource found through the JNDI lookup when a connection is obtained is saved in the DBConnectionSpec. If the DBConnectionSpec is used again to obtain a connection, the connection can be obtained from the DataSource without requiring a JNDI lookup again.
If two beans share the same DBConnectionSpec, it does not mean that they will share the same database connection. To make two beans share the same connection use the DBStatement.shareConnectionWith() method.
Constructor Summary | |
---|---|
DBConnectionSpec()
The default constructor |
Method Summary | |
---|---|
java.lang.String |
getDataSourceName()
Gets the JNDI name of the javax.sql.DataSource to use when opening a database connection. |
java.lang.String |
getDriverName()
Gets the class name of the JDBC driver that will automatically be loaded and registered for you before using the DriverManager to open a database connection. |
java.lang.String |
getInitialContextFactory()
Gets the class name of the InitialContextFactory that will be used to locate a javax.sql.DataSource. |
java.lang.Object |
getInternalUseObject(int aType)
For Internal Use only. |
java.io.PrintWriter |
getLogWriter()
Gets the PrintWriter being used to log any error information written by this bean. |
java.lang.String |
getPassword()
Returns a String of asterisks (*) the length of the password used to create a database connection. |
boolean |
getPromptUID()
Gets the class name of the InitialContextFactory that will be used to locate a javax.sql.DataSource. |
java.util.Properties |
getProperties()
Returns the connection properties for this DBConnectionSpec. |
java.lang.String |
getProviderUrl()
Gets the URL of the machine where the naming service should look for a javax.sql.DataSource. |
java.lang.String |
getUrl()
Gets the url of the database to connect to using the DriverManager. |
java.lang.String |
getUsername()
Gets the user name used to create a database connection. |
void |
setDataSourceName(java.lang.String aName)
Specifies the name of a javax.sql.DataSource to use when opening a database connection, and clears any value previously set for the url property. |
void |
setDriverName(java.lang.String aDriverName)
Specifies the class name of a JDBC driver that will automatically be loaded and registered for you before using the DriverManager to open a database connection. |
void |
setInitialContextFactory(java.lang.String aInitialContextFactory)
Specifies the class name of the InitialContextFactory that will be used to locate a javax.sql.DataSource. |
void |
setInternalUseObject(java.lang.Object aDataSource)
For Internal Use only. |
void |
setLogWriter(java.io.PrintWriter out)
Provides the PrintWriter that will be used to log any error information written by this bean. |
void |
setPassword(java.lang.String aPassword)
Sets the password used to create a database connection. |
void |
setPassword(java.lang.String aPassword,
boolean decode)
Sets the password used to create a database connection. |
void |
setProperties(java.util.Properties properties)
Sets the connection properties to use when establishing a connection. |
void |
setProviderUrl(java.lang.String aProviderUrl)
Specifies the URL of the machine where the naming service should look for a javax.sql.DataSource. |
void |
setUrl(java.lang.String aUrl)
Specifies the url of the database to connect to using the DriverManager, and clears any value previously set for the dataSourceName property. |
void |
setUsername(java.lang.String aName)
Sets the user name used to create a database connection. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DBConnectionSpec()
Method Detail |
public java.lang.String getDataSourceName()
When a connection is established, either the dataSourceName property or the url property is used, whichever was specified most recently. If the dataSourceName is used, a connection is established via a javax.sql.DataSource object. If the url is used, a connection is established via the Driver Manager.
setDataSourceName(java.lang.String)
,
getInitialContextFactory()
,
getProviderUrl()
public java.lang.String getDriverName()
If this property is null or an empty string, no driver will be automaticaly loaded and registered. It may still be possible to connect via the DriverManager if an appropriate driver has been loaded and registered independently of this bean.
This property is only used if the url property is not null. If the url property is null, then this field is ignored and the connection is obtained using the DataSource specified in the dataSourceName property.
setDriverName(java.lang.String)
,
getUrl()
public java.lang.String getInitialContextFactory()
If this property is null, the default InitialContextFactory identified by the java.naming.factory.initial property in your java environment will be used.
This property is only used if the dataSourceName property is not null. If the dataSourceName property is null, then this field is ignored and the connection is obtained using the DriverManager.
setInitialContextFactory(java.lang.String)
,
getDriverName()
,
getProviderUrl()
public java.lang.Object getInternalUseObject(int aType)
public java.io.PrintWriter getLogWriter()
The default log writer logs to the Java console. When this property is set to null, no information is logged.
setLogWriter(java.io.PrintWriter)
public java.lang.String getPassword()
setPassword(String)
,
setPassword(String, boolean)
public boolean getPromptUID()
If this property is null, the default InitialContextFactory identified by the java.naming.factory.initial property in your java environment will be used.
This property is only used if the dataSourceName property is not null. If the dataSourceName property is null, then this field is ignored and the connection is obtained using the DriverManager.
setInitialContextFactory(java.lang.String)
,
getDriverName()
,
getProviderUrl()
public java.util.Properties getProperties()
setProperties(java.util.Properties)
,
getUsername()
,
getPassword()
public java.lang.String getProviderUrl()
If this property is null, the naming service will look on the local host.
This property is only used if the dataSourceName property is not null. If the dataSourceName property is null, then this field is ignored and the connection is obtained using the DriverManager.
setProviderUrl(java.lang.String)
,
getDataSourceName()
,
getInitialContextFactory()
public java.lang.String getUrl()
When a connection is established, either the dataSourceName property or the url property is used, whichever was specified most recently. If the dataSourceName is used, a connection is established via a javax.sql.DataSource object. If the url is used, a connection is established via the Driver Manager.
setUrl(java.lang.String)
,
getDriverName()
public java.lang.String getUsername()
setUsername(java.lang.String)
public void setDataSourceName(java.lang.String aName)
When a connection is established, either the dataSourceName property or the url property is used, whichever was specified most recently. If the dataSourceName is used, a connection is established via a javax.sql.DataSource object. If the url is used, a connection is established via the Driver Manager.
getDataSourceName()
,
setInitialContextFactory(java.lang.String)
,
setProviderUrl(java.lang.String)
public void setDriverName(java.lang.String aDriverName)
COM.ibm.db2.jdbc.appDB2Driver
.
If this property is null or an empty string, no driver will be automaticaly loaded and registered. It may still be possible to connect via the DriverManager if an appropriate driver has been loaded and registered independently of this bean.
This property is only used if the url property is not null. If the url property is null, then this field is ignored and the connection is obtained using the DataSource specified in the dataSourceName property.
getDriverName()
,
setUrl(java.lang.String)
public void setInitialContextFactory(java.lang.String aInitialContextFactory)
com.ibm.ejs.ns.jndi.CNInitialContextFactory
.
If you set this property to null, the default InitialContextFactory identified by the property java.naming.factory.initial in your java environment will be used.
This property is only used if the dataSourceName property is not null. If the dataSourceName property is null, then this field is ignored and the connection is obtained using the DriverManager.
getInitialContextFactory()
,
setDataSourceName(java.lang.String)
,
setProviderUrl(java.lang.String)
public void setInternalUseObject(java.lang.Object aDataSource)
public void setLogWriter(java.io.PrintWriter out)
If you do not explicitly use this method to provide a PrintWriter, information is logged by default to the Java console. If you wish to have no information logged, you can provide a null value here. If you wish to have log information for this bean and log information for your database written to the same place, provide the same PrintWriter for both the DriverManager.setLogWriter() method and this method.
out
- the PrintWriter that will be used for logginggetLogWriter()
public void setPassword(java.lang.String aPassword)
getPassword()
,
setPassword(String, boolean)
public void setPassword(java.lang.String aPassword, boolean decode) throws DBException
DBException
- decodeError
- if password cannot be decodedgetPassword()
,
setPassword(String)
public void setProperties(java.util.Properties properties)
properties
- the connection propertiesgetProperties()
,
setPassword(java.lang.String)
,
setUsername(java.lang.String)
public void setProviderUrl(java.lang.String aProviderUrl)
If you set this property to null, the naming service will look on the local host.
This property is only used if the dataSourceName property is not null. If the dataSourceName property is null, then this field is ignored and the connection is obtained using the DriverManager.
getProviderUrl()
,
setDataSourceName(java.lang.String)
,
setInitialContextFactory(java.lang.String)
public void setUrl(java.lang.String aUrl)
When a connection is established, either the dataSourceName property or the url property is used, whichever was specified most recently. If the dataSourceName is used, a connection is established via a javax.sql.DataSource object. If the url is used, a connection is established via the Driver Manager.
To connect using the Driver Manager, you must either insure that a driver
that accepts the url has been loaded and registered, or use the
setDriverName
method to cause such a driver to be automatically
loaded and registered for you.
getUrl()
,
setDriverName(java.lang.String)
public void setUsername(java.lang.String aName)
getUsername()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |