public class JdbcThreadManagedConnectionAccess extends java.lang.Object implements JdbcConnectionAccessInterface
setConnection(Connection)
sets the connection of the current thread,
which is afterwards returned by the method getConnection()
. The
method closeConnection()
closes and releases the connection for the
current thread. The method releaseConnection()
is empty and has no
effect.
This connection access can be used in a multi threaded application as part of a singleton.
Constructor and Description |
---|
JdbcThreadManagedConnectionAccess() |
Modifier and Type | Method and Description |
---|---|
void |
closeConnection()
This method implements the interface
JdbcConnectionAccessInterface and closes and releases the database
connection of the current thread. |
java.sql.Connection |
getConnection()
This method implements the interface
JdbcConnectionAccessInterface and returns the database connection
for the current thread. |
void |
releaseConnection()
This method implements the interface
JdbcConnectionAccessInterface with an empty implementation. |
void |
setConnection(java.sql.Connection connection)
This method implements the interface
JdbcConnectionAccessInterface to sets the passed connection for the
current thread. |
public void closeConnection() throws JdbcGeneralError
JdbcConnectionAccessInterface
and closes and releases the database
connection of the current thread.closeConnection
in interface JdbcConnectionAccessInterface
JdbcGeneralError
- Thrown, when closing the connection fails.public java.sql.Connection getConnection() throws JdbcGeneralError
JdbcConnectionAccessInterface
and returns the database connection
for the current thread.getConnection
in interface JdbcConnectionAccessInterface
JdbcGeneralError
- May be thrown by derived classes.public void releaseConnection() throws JdbcGeneralError
JdbcConnectionAccessInterface
with an empty implementation.releaseConnection
in interface JdbcConnectionAccessInterface
JdbcGeneralError
- May be thrown by derived classes.public void setConnection(java.sql.Connection connection)
JdbcConnectionAccessInterface
to sets the passed connection for the
current thread. After calling this method, the method getConnection()
returns the passed connection for the current thread.
A previously connection opened by the current thread is discarded and no
longer accessible via this class. When null is passed as
connection, the connection of the current thread is removed, but not
closed.setConnection
in interface JdbcConnectionAccessInterface
connection
- The connection to be set, or null when the
connection should be removed for the current thread.