|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.easybeans.dbpool.JManagedConnection
public class JManagedConnection
This class represents the connection managed by the pool. This connection is a managed connection and is notified of the transaction events.
Field Summary | |
---|---|
private long |
closeTime
Time for closing this connection. |
private long |
deathTime
Time of the death for this connection. |
private ConnectionManager |
ds
Link to the connection manager. |
private java.util.Vector<javax.sql.ConnectionEventListener> |
eventListeners
Event listeners (of PooledConnection). |
private int |
identifier
Identifier of this connection. |
private java.sql.Connection |
implConn
Connection returned to the user. |
private static JLog |
logger
Logger. |
private static int |
objcount
Counter of all managed connections created. |
private int |
open
count of opening this connection. |
private java.sql.Connection |
physicalConnection
Connection to the database. |
private java.util.Map<java.lang.String,JStatement> |
psList
List of PreparedStatement in the pool. |
private int |
psOpenNb
Current number of opened prepared statements. |
private int |
pstmtmax
Maximum of prepared statements. |
private int |
reUsedPreparedStatements
Prepared statements that were reused. |
private int |
timeout
Transaction timeout value. |
private javax.transaction.Transaction |
tx
Transaction the connection is involved with. |
Fields inherited from interface javax.transaction.xa.XAResource |
---|
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY |
Constructor Summary | |
---|---|
JManagedConnection(java.sql.Connection physicalConnection,
ConnectionManager ds)
Builds a new managed connection on a JDBC connection. |
Method Summary | |
---|---|
void |
addConnectionEventListener(javax.sql.ConnectionEventListener listener)
Add an event listener. |
void |
afterCompletion(int status)
synchronization implementation. |
void |
beforeCompletion()
synchronization implementation. |
void |
close()
Close the database connection. |
void |
commit(javax.transaction.xa.Xid xid,
boolean onePhase)
Commit the global transaction specified by xid. |
int |
compareTo(java.lang.Object o)
Compares this object with another specified object. |
void |
end(javax.transaction.xa.Xid xid,
int flags)
Ends the work performed on behalf of a transaction branch. |
void |
forget(javax.transaction.xa.Xid xid)
Tell the resource manager to forget about a heuristically completed transaction branch. |
java.sql.Connection |
getConnection()
Create an object handle for a database connection. |
int |
getIdentifier()
|
int |
getOpenCount()
|
int |
getReUsedPreparedStatements()
|
int |
getTransactionTimeout()
Obtain the current transaction timeout value set for this XAResource instance. |
javax.transaction.Transaction |
getTx()
|
javax.transaction.xa.XAResource |
getXAResource()
Return an XA resource to the caller. |
void |
hold()
Notify as opened. |
boolean |
inactive()
Check if the connection has been unused for too long time. |
boolean |
isAged()
|
boolean |
isClosed()
|
boolean |
isOpen()
|
boolean |
isSameRM(javax.transaction.xa.XAResource xares)
Determine if the resource manager instance represented by the target object is the same as the resource manager instance represented by the parameter xares. |
void |
notifyClose()
Notify a Close event on Connection. |
void |
notifyError(java.sql.SQLException ex)
Notify an Error event on Connection. |
void |
notifyPsClose(JStatement ps)
A PreparedStatement has been logically closed. |
int |
prepare(javax.transaction.xa.Xid xid)
Ask the resource manager to prepare for a transaction commit of the transaction specified in xid. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
Try to find a PreparedStatement in the pool. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Try to find a PreparedStatement in the pool for the given options. |
javax.transaction.xa.Xid[] |
recover(int flag)
Obtain a list of prepared transaction branches from a resource manager. |
boolean |
release()
notify as closed. |
void |
remove()
remove this item, ignoring exception on close. |
void |
removeConnectionEventListener(javax.sql.ConnectionEventListener listener)
Remove an event listener. |
void |
rollback(javax.transaction.xa.Xid xid)
Inform the resource manager to roll back work done on behalf of a transaction branch. |
void |
setPstmtMax(int max)
Dynamically change the prepared statement pool size. |
boolean |
setTransactionTimeout(int seconds)
Set the current transaction timeout value for this XAResource instance. |
void |
setTx(javax.transaction.Transaction tx)
Set the associated transaction. |
void |
start(javax.transaction.xa.Xid xid,
int flags)
Start work on behalf of a transaction branch specified in xid. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static JLog logger
private java.sql.Connection physicalConnection
private java.sql.Connection implConn
private int pstmtmax
private int psOpenNb
private java.util.Vector<javax.sql.ConnectionEventListener> eventListeners
private int open
private int timeout
private javax.transaction.Transaction tx
private static int objcount
private final int identifier
private int reUsedPreparedStatements
private java.util.Map<java.lang.String,JStatement> psList
private ConnectionManager ds
private long deathTime
private long closeTime
Constructor Detail |
---|
public JManagedConnection(java.sql.Connection physicalConnection, ConnectionManager ds)
physicalConnection
- the physical JDBC Connection.ds
- the connection managerMethod Detail |
---|
public int getIdentifier()
public void setPstmtMax(int max)
max
- the maximum of prepared statement.public void commit(javax.transaction.xa.Xid xid, boolean onePhase) throws javax.transaction.xa.XAException
commit
in interface javax.transaction.xa.XAResource
xid
- transaction xidonePhase
- true if one phase commit
javax.transaction.xa.XAException
- XA protocol errorpublic void end(javax.transaction.xa.Xid xid, int flags) throws javax.transaction.xa.XAException
end
in interface javax.transaction.xa.XAResource
xid
- transaction xidflags
- currently unused
javax.transaction.xa.XAException
- XA protocol errorpublic void forget(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
forget
in interface javax.transaction.xa.XAResource
xid
- transaction xid
javax.transaction.xa.XAException
- XA protocol errorpublic int getTransactionTimeout() throws javax.transaction.xa.XAException
getTransactionTimeout
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
- XA protocol errorpublic boolean isSameRM(javax.transaction.xa.XAResource xares) throws javax.transaction.xa.XAException
isSameRM
in interface javax.transaction.xa.XAResource
xares
- An XAResource object
javax.transaction.xa.XAException
- XA protocol errorpublic int prepare(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
prepare
in interface javax.transaction.xa.XAResource
xid
- transaction xid
javax.transaction.xa.XAException
- XA protocol errorpublic javax.transaction.xa.Xid[] recover(int flag) throws javax.transaction.xa.XAException
recover
in interface javax.transaction.xa.XAResource
flag
- unused parameter.
javax.transaction.xa.XAException
- XA protocol errorpublic void rollback(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
rollback
in interface javax.transaction.xa.XAResource
xid
- transaction xid
javax.transaction.xa.XAException
- XA protocol errorpublic boolean setTransactionTimeout(int seconds) throws javax.transaction.xa.XAException
setTransactionTimeout
in interface javax.transaction.xa.XAResource
seconds
- timeout value, in seconds.
javax.transaction.xa.XAException
- XA protocol errorpublic void start(javax.transaction.xa.Xid xid, int flags) throws javax.transaction.xa.XAException
start
in interface javax.transaction.xa.XAResource
xid
- transaction xidflags
- unused parameter
javax.transaction.xa.XAException
- XA protocol errorpublic javax.transaction.xa.XAResource getXAResource() throws java.sql.SQLException
getXAResource
in interface javax.sql.XAConnection
java.sql.SQLException
- - if a database-access error occurspublic int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
o
- the object to compare
public int getReUsedPreparedStatements()
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface javax.sql.PooledConnection
java.sql.SQLException
- - if a database-access error occurspublic void close() throws java.sql.SQLException
close
in interface javax.sql.PooledConnection
java.sql.SQLException
- - if a database-access error occurspublic void addConnectionEventListener(javax.sql.ConnectionEventListener listener)
addConnectionEventListener
in interface javax.sql.PooledConnection
listener
- event listenerpublic void removeConnectionEventListener(javax.sql.ConnectionEventListener listener)
removeConnectionEventListener
in interface javax.sql.PooledConnection
listener
- event listenerpublic void beforeCompletion()
beforeCompletion
in interface javax.transaction.Synchronization
public void afterCompletion(int status)
afterCompletion
in interface javax.transaction.Synchronization
public boolean isAged()
public boolean isOpen()
public int getOpenCount()
public boolean inactive()
public boolean isClosed()
public void hold()
public boolean release()
public void setTx(javax.transaction.Transaction tx)
tx
- Transactionpublic javax.transaction.Transaction getTx()
public void remove()
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
sql
- the sql of the prepared statementresultSetType
- the type of resultsetresultSetConcurrency
- the concurrency of this resultset
java.sql.SQLException
- if an errors occurs on the database.public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
sql
- the given sql query.
java.sql.SQLException
- if an error in the database occurs.public void notifyPsClose(JStatement ps)
ps
- a prepared statement.public void notifyClose()
public void notifyError(java.sql.SQLException ex)
ex
- the given exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |