public abstract class AbstractDataSource extends Object implements DataSource, Serializable, DataSource, javax.resource.Referenceable
java.sql.Connection object, which is to be
passed to the application program.| Modifier and Type | Field and Description |
|---|---|
protected static Logger |
_logger |
protected MethodExecutor |
executor |
protected ManagedConnectionFactoryImpl |
mcf |
| Constructor and Description |
|---|
AbstractDataSource(ManagedConnectionFactoryImpl mcf,
javax.resource.spi.ConnectionManager cm)
Constructs
DataSource object. |
| Modifier and Type | Method and Description |
|---|---|
Connection |
getConnection()
Retrieves the
Connection object. |
Connection |
getConnection(Connection con)
Retrieves the actual SQLConnection from the Connection wrapper
implementation of SunONE application server.
|
Connection |
getConnection(String user,
String pwd)
Retrieves the
Connection object. |
String |
getDescription()
Retrieves the description.
|
int |
getLoginTimeout()
Get the login timeout
|
PrintWriter |
getLogWriter()
Get the logwriter object.
|
Connection |
getNonTxConnection()
Gets a connection that is not in the scope of any transaction.
|
Connection |
getNonTxConnection(String user,
String password)
Gets a connection that is not in the scope of any transaction.
|
Reference |
getReference()
Get the reference.
|
void |
markConnectionAsBad(Connection conn)
API to mark a connection as bad.
|
void |
setDescription(String description)
Set the description.
|
void |
setLoginTimeout(int loginTimeout)
Set the login timeout
|
void |
setLogWriter(PrintWriter logWriter)
Set the logwriter on this object.
|
void |
setReference(Reference reference)
Get the reference.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetParentLoggerisWrapperFor, unwrapprotected ManagedConnectionFactoryImpl mcf
protected MethodExecutor executor
protected static final Logger _logger
public AbstractDataSource(ManagedConnectionFactoryImpl mcf, javax.resource.spi.ConnectionManager cm)
DataSource object. This is created by the
ManagedConnectionFactory object.mcf - ManagedConnectionFactory object
creating this object.cm - ConnectionManager object either associated
with Application server or Resource Adapter.public Connection getConnection() throws SQLException
Connection object.getConnection in interface DataSource Connection object.SQLException - In case of an error.public Connection getConnection(String user, String pwd) throws SQLException
Connection object.getConnection in interface DataSourceuser - User name for the Connection.pwd - Password for the Connection. Connection object.SQLException - In case of an error.public Connection getConnection(Connection con) throws SQLException
con - Connection obtained from Datasource.getConnection()java.sql.Connection implementation of the driver.java.sql.SQLException - If connection cannot be obtained.SQLExceptionpublic Connection getNonTxConnection() throws SQLException
java.sql.Connectionjava.sql.SQLException - If connection cannot be obtainedSQLExceptionpublic Connection getNonTxConnection(String user, String password) throws SQLException
user - User name for authenticating the connectionpassword - Password for authenticating the connectionjava.sql.Connectionjava.sql.SQLException - If connection cannot be obtainedSQLExceptionpublic int getLoginTimeout()
throws SQLException
getLoginTimeout in interface CommonDataSourceSQLException - If a database error occurs.public void setLoginTimeout(int loginTimeout)
throws SQLException
setLoginTimeout in interface CommonDataSourceloginTimeout - Login timeout.SQLException - If a database error occurs.public PrintWriter getLogWriter() throws SQLException
getLogWriter in interface CommonDataSource PrintWriter object.SQLException - If a database error occurs.public void setLogWriter(PrintWriter logWriter) throws SQLException
setLogWriter in interface CommonDataSourcelogWriter - object.SQLException - If a database error occurs.public String getDescription()
public void setDescription(String description)
description - Description about the DataSource.public Reference getReference()
getReference in interface ReferenceableReferenceobject.public void setReference(Reference reference)
reference - Reference object.public void markConnectionAsBad(Connection conn)
com.sun.appserv.jdbc.DataSource ds=
(com.sun.appserv.jdbc.DataSource)context.lookup("dataSource");
Connection con = ds.getConnection();
Statement stmt = null;
try{
stmt = con.createStatement();
stmt.executeUpdate("Update");
}catch(BadConnectionException e){
dataSource.markConnectionAsBad(con) //marking it as bad for removal
}finally{
stmt.close();
con.close(); //Connection will be destroyed while close or Tx completion
}
conn - java.sql.ConnectionCopyright © 2017. All rights reserved.