Methods Summary |
---|
private ConnectionHolder.ConnectionType | findConnectionType()
ConnectionHolder.ConnectionType cmType = ConnectionHolder.ConnectionType.STANDARD;
if (cm instanceof javax.resource.spi.LazyAssociatableConnectionManager) {
if (!((com.sun.enterprise.connectors.ConnectionManagerImpl) cm).
getJndiName().endsWith(ConnectorConstants.PM_JNDI_SUFFIX)) {
cmType = ConnectionHolder.ConnectionType.LAZY_ASSOCIATABLE;
}
} else if (cm instanceof
javax.resource.spi.LazyEnlistableConnectionManager) {
if (!((com.sun.enterprise.connectors.ConnectionManagerImpl) cm).
getJndiName().endsWith(ConnectorConstants.PM_JNDI_SUFFIX) &&
!((com.sun.enterprise.connectors.ConnectionManagerImpl) cm).
getJndiName().endsWith(ConnectorConstants.NON_TX_JNDI_SUFFIX)) {
cmType = ConnectionHolder.ConnectionType.LAZY_ENLISTABLE;
}
}
return cmType;
|
public java.sql.Connection | getConnection()Retrieves the Connection object.
try {
ConnectionHolder con = (ConnectionHolder)
cm.allocateConnection(mcf, null);
setConnectionType(con);
return con;
} catch (ResourceException re) {
_logger.log(Level.WARNING, "jdbc.exc_get_conn", re.getMessage());
throw new SQLException(re.getMessage());
}
|
public java.sql.Connection | getConnection(java.lang.String user, java.lang.String pwd)Retrieves the Connection object.
try {
ConnectionRequestInfo info = new ConnectionRequestInfo(user, pwd);
ConnectionHolder con = (ConnectionHolder)
cm.allocateConnection(mcf, info);
setConnectionType(con);
return con;
} catch (ResourceException re) {
_logger.log(Level.WARNING, "jdbc.exc_get_conn", re.getMessage());
throw new SQLException(re.getMessage());
}
|
public java.sql.Connection | getConnection(java.sql.Connection con)Retrieves the actual SQLConnection from the Connection wrapper
implementation of SunONE application server. If an actual connection is
supplied as argument, then it will be just returned.
Connection driverCon = con;
if (con instanceof com.sun.gjc.spi.base.ConnectionHolder) {
driverCon = ((com.sun.gjc.spi.base.ConnectionHolder) con).getConnection();
}
return driverCon;
|
public java.lang.String | getDescription()Retrieves the description.
return description;
|
public java.io.PrintWriter | getLogWriter()Get the logwriter object.
return logWriter;
|
public int | getLoginTimeout()Get the login timeout
return loginTimeout;
|
public java.sql.Connection | getNonTxConnection()Gets a connection that is not in the scope of any transaction. This
can be used to save performance overhead incurred on enlisting/delisting
each connection got, irrespective of whether its required or not.
Note here that this meethod does not fit in the connector contract
per se.
try {
ConnectionHolder con = (ConnectionHolder)
((com.sun.enterprise.connectors.ConnectionManagerImpl)
cm).allocateNonTxConnection(mcf, null);
setConnectionType(con, true);
return con;
} catch (ResourceException re) {
_logger.log(Level.WARNING, "jdbc.exc_get_conn", re.getMessage());
throw new SQLException(re.getMessage());
}
|
public java.sql.Connection | getNonTxConnection(java.lang.String user, java.lang.String password)Gets a connection that is not in the scope of any transaction. This
can be used to save performance overhead incurred on enlisting/delisting
each connection got, irrespective of whether its required or not.
Note here that this meethod does not fit in the connector contract
per se.
try {
ConnectionRequestInfo cxReqInfo = new ConnectionRequestInfo(user, password);
ConnectionHolder con = (ConnectionHolder)
((com.sun.enterprise.connectors.ConnectionManagerImpl)
cm).allocateNonTxConnection(mcf, cxReqInfo);
setConnectionType(con, true);
return con;
} catch (ResourceException re) {
_logger.log(Level.WARNING, "jdbc.exc_get_conn", re.getMessage());
throw new SQLException(re.getMessage());
}
|
public javax.naming.Reference | getReference()Get the reference.
return reference;
|
public void | markConnectionAsBad(java.sql.Connection conn)API to mark a connection as bad. If the application can determine that the connection
is bad, using this api, it can notify the resource-adapter which inturn will notify the
connection-pool. Connection-pool will drop and create a new connection.
eg:
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
}
if (conn instanceof ConnectionHolder) {
ConnectionHolder userConn = ((ConnectionHolder) conn);
userConn.getManagedConnection().markForRemoval(true);
}
|
private void | setConnectionType(ConnectionHolder con)
this.setConnectionType(con, false);
|
private void | setConnectionType(ConnectionHolder con, boolean isNonTx)
con.setConnectionType(conType_);
if (conType_ == ConnectionHolder.ConnectionType.LAZY_ASSOCIATABLE) {
con.setLazyAssociatableConnectionManager(
(javax.resource.spi.LazyAssociatableConnectionManager) cm);
} else if (conType_ == ConnectionHolder.ConnectionType.LAZY_ENLISTABLE) {
if (isNonTx) {
//if this is a getNonTxConnection call on the DataSource, we
//should not LazyEnlist
con.setConnectionType(ConnectionHolder.ConnectionType.STANDARD);
} else {
con.setLazyEnlistableConnectionManager(
(javax.resource.spi.LazyEnlistableConnectionManager) cm);
}
}
|
public void | setDescription(java.lang.String description)Set the description.
this.description = description;
|
public void | setLogWriter(java.io.PrintWriter logWriter)Set the logwriter on this object.
this.logWriter = logWriter;
|
public void | setLoginTimeout(int loginTimeout)Set the login timeout
this.loginTimeout = loginTimeout;
|
public void | setReference(javax.naming.Reference reference)Get the reference.
this.reference = reference;
|