|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tyrex.resource.jdbc.xa.XADataSourceImpl tyrex.resource.jdbc.xa.EnabledDataSource
Implements a JDBC 2.0 DataSource
for any
arbitrary JDBC driver with JNDI persistance support. XA and pooled
connection support is also available, but the application must
used the designated DataSource interface to obtain them.
The driver class name setDriverClassName(java.lang.String)
specifies the
class of the JDBC driver to be loaded.
The JDBC URL is specified by setDriverName(java.lang.String)
. The JDBC URL
is of the form jdbc:subprotocol:subname. The initial "jdbc:" is optional
so that subprocol:subname is also valid.
The supported data source properties are:
driverName (required) description (required, default) loginTimeout (required, default from driver) driverClassName (optional) user (optional) password (optional) transactionTimeout (optional, default from driver) isolationLevel (optional, defaults to serializable)This data source may be serialized and stored in a JNDI directory. Example of how to create a new data source and register it with JNDI:
EnabledDataSource ds; InitialContext ctx; ds = new EnabledDataSource(); ds.setDriverClassName( "..." ); ds.setDriverName( "jdbc:subprotocol:subname" ); ds.setUser( "me" ); ds.setPassword( "secret" ); ctx = new InitialContext(); ctx.rebind( "/comp/jdbc/test", ds );Example for obtaining the data source from JNDI and opening a new connections:
InitialContext ctx; DataSource ds; ctx = new InitialContext(); ds = (DataSource) ctx.lookup( "/comp/jdbc/test" ); ds.getConnection();
XADataSourceImpl
,
DataSource
,
Connection
,
Serialized FormField Summary |
Fields inherited from class tyrex.resource.jdbc.xa.XADataSourceImpl |
DEFAULT_ISOLATION_LEVEL, DEFAULT_TX_TIMEOUT |
Constructor Summary | |
EnabledDataSource()
|
Method Summary | |
protected java.lang.String |
createJDBCURL()
Construct the JDBC URL used to connect to the database. |
boolean |
equals(java.lang.Object other)
Returns true if this datasource and the other are equal. |
java.sql.Connection |
getConnection()
|
java.sql.Connection |
getConnection(java.lang.String user,
java.lang.String password)
|
java.lang.String |
getDescription()
Returns the description of this datasource. |
java.lang.String |
getDriverClassName()
Returns the class name of the JDBC driver to use. |
java.lang.String |
getDriverName()
Returns the URL name of the JDBC driver to use. |
java.lang.String |
getIsolationLevelAsString()
Returns the transaction isolation level used with all new transactions, or null if the driver's default isolation level is used. |
int |
getLoginTimeout()
|
java.io.PrintWriter |
getLogWriter()
This method is defined in the interface and implemented in the derived class, we re-define it just to make sure it does not throw an SQLException and that we do not need to
catch one. |
java.lang.Object |
getObjectInstance(java.lang.Object refObj,
javax.naming.Name name,
javax.naming.Context nameCtx,
java.util.Hashtable env)
|
java.lang.String |
getPassword()
Returns the database password. |
javax.naming.Reference |
getReference()
|
java.lang.String |
getUser()
Returns the user's account name. |
void |
setDescription(java.lang.String description)
Sets the description of this datasource. |
void |
setDriverClassName(java.lang.String className)
Sets the class name of the JDBC driver to use, e.g. |
void |
setDriverName(java.lang.String driverName)
Sets the JDBC URL for the JDBC driver to use. |
void |
setIsolationLevel(java.lang.String level)
Sets the transaction isolation level used with all new transactions, or null if the driver's default isolation level should be used. |
void |
setLoginTimeout(int seconds)
|
void |
setLogWriter(java.io.PrintWriter writer)
|
void |
setPassword(java.lang.String password)
Sets the database password. |
void |
setUser(java.lang.String user)
Sets the user's account name. |
java.lang.String |
toString()
|
Methods inherited from class tyrex.resource.jdbc.xa.XADataSourceImpl |
debug, getIgnoreIsolationLevel, getIsolationLevel, getPooledConnection, getPooledConnection, getPruneFactor, getTransactionTimeout, getTxConnection, getTxRecover, getXAConnection, getXAConnection, newConnection, releaseConnection, run, setIgnoreIsolationLevel, setIsolationLevel, setPruneFactor, setTransactionTimeout, setTxConnection |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public EnabledDataSource()
Method Detail |
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public java.sql.Connection getConnection(java.lang.String user, java.lang.String password) throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
protected java.lang.String createJDBCURL()
public java.io.PrintWriter getLogWriter()
XADataSourceImpl
SQLException
and that we do not need to
catch one.
getLogWriter
in interface javax.sql.DataSource
getLogWriter
in class XADataSourceImpl
public void setLogWriter(java.io.PrintWriter writer)
setLogWriter
in interface javax.sql.DataSource
public void setDriverName(java.lang.String driverName)
driverName
- The URL name of the JDBC driver to usepublic java.lang.String getDriverName()
public void setDriverClassName(java.lang.String className)
className
- The class name of the JDBC driver to usepublic java.lang.String getDriverClassName()
public void setLoginTimeout(int seconds)
setLoginTimeout
in interface javax.sql.DataSource
public int getLoginTimeout()
getLoginTimeout
in interface javax.sql.DataSource
public void setDescription(java.lang.String description)
description
- The description of this datasourcepublic java.lang.String getDescription()
public void setPassword(java.lang.String password)
password
- The database passwordpublic java.lang.String getPassword()
public void setUser(java.lang.String user)
user
- The user's account namepublic java.lang.String getUser()
public java.lang.String getIsolationLevelAsString()
setIsolationLevel(java.lang.String)
.
public void setIsolationLevel(java.lang.String level)
level
- The transaction isolation levelpublic boolean equals(java.lang.Object other)
public java.lang.String toString()
public javax.naming.Reference getReference()
getReference
in interface javax.naming.Referenceable
public java.lang.Object getObjectInstance(java.lang.Object refObj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable env) throws javax.naming.NamingException
getObjectInstance
in interface javax.naming.spi.ObjectFactory
javax.naming.NamingException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |