|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tentackle.db.ManagedConnection
public class ManagedConnection
A jdbc connection managed by the ConnectionManager.
The connection provides some additional features
such as a prepared statement cache
and translates SQLExceptions to DbRuntimeExceptions.
The ConnectionManager is responsible to attach and detach
the connection to a Db.
| Constructor Summary | |
|---|---|
ManagedConnection(ConnectionManager manager,
Connection connection)
Creates a managed connection. |
|
| Method Summary | |
|---|---|
void |
attachDb(Db db)
Attaches a connection to a Db. |
void |
close()
Closes the connection. |
void |
closeAllPreparedStatements(boolean onlyMarked)
Closes all prepared statements. |
void |
commit()
Performs a commit. |
void |
countForClearWarnings()
Increments a counter and empties the warnings on the connection and all prepared statements if a trigger value is reached. |
Statement |
createStatement(Db db)
Creates a one-shot statement. |
Statement |
createStatement(Db db,
int resultSetType)
Creates a one-shot statement. |
Statement |
createStatement(Db db,
int resultSetType,
int resultSetConcurrency)
Creates a one-shot statement. |
void |
detachDb(Db db)
Detaches a connection. |
boolean |
getAutoCommit()
Gets the autocommit value. |
Connection |
getConnection()
Gets the low level connection. |
Db |
getDb()
Gets tha attached db. |
long |
getDetachedSince()
Gets the epochal time when this connection was detached. |
long |
getEstablishedSince()
Gets the epochal time when this connection was established. |
long |
getExpireAt()
Gets the epochal time when this connection should be closed, if unused. |
int |
getIndex()
Gets the connection index. |
ConnectionManager |
getManager()
Gets the connection manager |
int |
getMaxCountForClearWarnings()
Gets the current setting for clearWarnings() trigger. |
PreparedStatementWrapper |
getPreparedStatement(int stmtId)
Gets a prepared statement. |
boolean |
isAttached()
Checks whether a Db is attached to this connection. |
boolean |
isClosed()
Gets the connection's closed state. |
boolean |
isDead()
Returns whether connection is marked dead |
void |
logAndClearWarnings()
Reads all warnings, logs them and clear. |
void |
rollback()
Performs a rollback. |
void |
setAutoCommit(boolean autoCommit)
Sets the autocommit feature. |
void |
setDead(boolean dead)
Marks a connection being dead. |
void |
setExpireAt(long expireAt)
Sets the epochal time when this connection should be closed, if unused. |
void |
setIndex(int index)
Sets the connection index. |
void |
setMaxCountForClearWarnings(int max)
Sets the countForClearWarnings trigger. |
String |
toString()
Gets the string representation of this connection. |
boolean |
verifyConnection()
Checks whether connection is still valid. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ManagedConnection(ConnectionManager manager,
Connection connection)
manager - the connection managerconnection - the low level JDBC connection| Method Detail |
|---|
public ConnectionManager getManager()
public Connection getConnection()
public long getEstablishedSince()
public void setExpireAt(long expireAt)
expireAt - the time in [ms], 0 = foreverpublic long getExpireAt()
public long getDetachedSince()
Note that newly created conntections get their detach time initialized from the current system time.
public void setIndex(int index)
index - the connection indexpublic int getIndex()
public void setDead(boolean dead)
Marking connections dead allows connection managers like
MpxConnectionManager to re-open connections before
being attached next time. Notice that not all connection managers
honour the dead-flag (makes only sense in servers, anyway).
Whenever the DefaultErrorHandler detects a communication link error,
it marks a connection dead.
dead - true if marked dead, false not deadpublic boolean isDead()
public boolean verifyConnection()
Implemented via a "SELECT 1" query. If the check fails the connection is marked dead.
public void attachDb(Db db)
db - the logical Db to attachpublic boolean isAttached()
public void detachDb(Db db)
db - the db to detachpublic Db getDb()
public String toString()
toString in class Objectpublic void setAutoCommit(boolean autoCommit)
autoCommit - true to enable autocomit, false to disable.public boolean getAutoCommit()
public void commit()
public void rollback()
public void logAndClearWarnings()
public void setMaxCountForClearWarnings(int max)
max - the maxcount, 0 = app must eat the warningspublic int getMaxCountForClearWarnings()
public void countForClearWarnings()
public void close()
public boolean isClosed()
public void closeAllPreparedStatements(boolean onlyMarked)
onlyMarked - true if close only pending statements
public Statement createStatement(Db db,
int resultSetType,
int resultSetConcurrency)
db - the Db to use for this one-shotresultSetType - a result set type; one of
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.TYPE_SCROLL_INSENSITIVE, or
ResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency - a concurrency type; one of
ResultSet.CONCUR_READ_ONLY or
ResultSet.CONCUR_UPDATABLE
Statement object that will generate
ResultSet objects with the given type and
concurrency
public Statement createStatement(Db db,
int resultSetType)
db - the Db to use for this one-shotresultSetType - a result set type; one of
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.TYPE_SCROLL_INSENSITIVE, or
ResultSet.TYPE_SCROLL_SENSITIVE
Statement object that will generate
ResultSet objects with the given type and
concurrency CONCUR_READ_ONLYpublic Statement createStatement(Db db)
db - the Db to use for this one-shot
Statement object that will generate
ResultSet objects with type TYPE_FORWARD_ONLY and
concurrency CONCUR_READ_ONLYpublic PreparedStatementWrapper getPreparedStatement(int stmtId)
stmtId - is the global statement id (> 0)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||