|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.mmbase.module.database.MultiConnection
MultiConnection is a replacement class for Connection it provides you a multiplexed and reuseable connections from the connection pool. The main function of this class is to 'log' (keep) the last sql statement passed to it. Another function is to keep state (i.e. notifying that it is busy), and to make itself available again to teh connectionpool once it is finished (closed).
| Field Summary | |
static int |
CON_BUSY
|
static int |
CON_FAILED
|
static int |
CON_FINISHED
|
static int |
CON_UNUSED
|
int |
state
|
| Fields inherited from interface java.sql.Connection |
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE |
| Constructor Summary | |
protected |
MultiConnection()
protected constructor for extending classes, so they can use this with for example only a connection.. |
|
MultiConnection(MultiPool parent,
java.sql.Connection con)
|
| Method Summary | |
protected boolean |
checkAfterException()
Tries to fix the this connection, if it proves to be broken. |
boolean |
checkSQLError(java.lang.Exception e)
|
void |
claim()
|
void |
clearWarnings()
clear Warnings |
void |
close()
Close connections |
void |
commit()
Perform commit |
java.sql.Statement |
createStatement()
createStatement returns an SQL Statement object |
java.sql.Statement |
createStatement(int i,
int y)
createStatement returns an SQL Statement object |
java.sql.Statement |
createStatement(int type,
int concurrency,
int holdability)
Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability. |
boolean |
getAutoCommit()
get AutoCommit mode |
java.lang.String |
getCatalog()
The "catalog" name |
int |
getHoldability()
Retrieves the current holdability of ResultSet objects created using this Connection object. |
java.lang.String |
getLastSQL()
|
java.sql.DatabaseMetaData |
getMetaData()
Advanced features: You can obtain a DatabaseMetaData object to get information about the target database. |
int |
getStartTime()
Returns the moment on which the last SQL statement was started in seconds after 1970. |
long |
getStartTimeMillis()
Returns the moment on which the last SQL statement was started in milliseconds after 1970. |
java.lang.String |
getStateString()
|
int |
getTransactionIsolation()
|
java.util.Map |
getTypeMap()
|
int |
getUsage()
|
java.sql.SQLWarning |
getWarnings()
getWarnings will return any warning information related to the current connection. |
boolean |
isClosed()
isClosed returns true if the connection is closed, which can occur either due to an explicit call on "close" or due to some fatal error on the connection. |
boolean |
isReadOnly()
Is this database readonly ? |
java.lang.String |
nativeSQL(java.lang.String query)
Convert the given generic SQL statement to the drivers native SQL. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql)
prepareCall create a pre-compiled SQL statement that is a call on a stored procedure. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int i,
int y)
prepareCall create a pre-compiled SQL statement that is a call on a stored procedure. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int type,
int concurrency,
int holdability)
Creates a CallableStatement object that will generate ResultSet objects with the given type, concurrency, and holdability. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
prepareStatement creates a pre-compiled SQL PreparedStatement object. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int autoGeneratedKeys)
Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int[] columnIndexes)
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int i,
int y)
prepareStatement creates a pre-compiled SQL PreparedStatement object. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int type,
int concurrency,
int holdability)
Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and holdability. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.String[] columnNames)
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. |
void |
realclose()
Close connections |
void |
release()
|
void |
releaseSavepoint(java.sql.Savepoint savepoint)
Removes the given Savepoint object from the current transaction. |
void |
rollback()
Perform rollback |
void |
rollback(java.sql.Savepoint savepoint)
Undoes all changes made after the given Savepoint object was set. |
void |
setAutoCommit(boolean enableAutoCommit)
If "autoCommit" is true, then all subsequent SQL statements will be executed and committed as individual transactions. |
void |
setCatalog(java.lang.String catalog)
The "catalog" selects a sub-space of the target database. |
void |
setHoldability(int holdability)
Changes the holdability of ResultSet objects created using this Connection object to the given holdability. |
void |
setLastSQL(java.lang.String sql)
|
void |
setReadOnly(boolean readOnly)
You can put a connection in read-only mode as a hint to enable database optimizations. |
java.sql.Savepoint |
setSavepoint()
Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it. |
java.sql.Savepoint |
setSavepoint(java.lang.String name)
Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it. |
void |
setTransactionIsolation(int level)
You can call the following method to try to change the transaction isolation level on a newly opened connection, using one of the TRANSACTION_* values. |
void |
setTypeMap(java.util.Map mp)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int CON_UNUSED
public static final int CON_BUSY
public static final int CON_FINISHED
public static final int CON_FAILED
public int state
| Constructor Detail |
protected MultiConnection()
public MultiConnection(MultiPool parent,
java.sql.Connection con)
| Method Detail |
public java.lang.String getStateString()
public void setLastSQL(java.lang.String sql)
public java.lang.String getLastSQL()
public java.sql.Statement createStatement()
throws java.sql.SQLException
createStatement in interface java.sql.Connectionjava.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLException
public java.sql.CallableStatement prepareCall(java.lang.String sql)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionjava.sql.SQLException
public java.lang.String nativeSQL(java.lang.String query)
throws java.sql.SQLException
nativeSQL in interface java.sql.Connectionjava.sql.SQLException
protected boolean checkAfterException()
throws java.sql.SQLException
public void setAutoCommit(boolean enableAutoCommit)
throws java.sql.SQLException
setAutoCommit in interface java.sql.Connectionjava.sql.SQLException
public boolean getAutoCommit()
throws java.sql.SQLException
getAutoCommit in interface java.sql.Connectionjava.sql.SQLException
public void commit()
throws java.sql.SQLException
commit in interface java.sql.Connectionjava.sql.SQLException
public void rollback()
throws java.sql.SQLException
rollback in interface java.sql.Connectionjava.sql.SQLException
public void close()
throws java.sql.SQLException
close in interface java.sql.Connectionjava.sql.SQLException
public void realclose()
throws java.sql.SQLException
java.sql.SQLException
public boolean isClosed()
throws java.sql.SQLException
isClosed in interface java.sql.Connectionjava.sql.SQLException
public java.sql.DatabaseMetaData getMetaData()
throws java.sql.SQLException
getMetaData in interface java.sql.Connectionjava.sql.SQLException
public void setReadOnly(boolean readOnly)
throws java.sql.SQLException
setReadOnly in interface java.sql.Connectionjava.sql.SQLException
public boolean isReadOnly()
throws java.sql.SQLException
isReadOnly in interface java.sql.Connectionjava.sql.SQLException
public void setCatalog(java.lang.String catalog)
throws java.sql.SQLException
setCatalog in interface java.sql.Connectionjava.sql.SQLException
public java.lang.String getCatalog()
throws java.sql.SQLException
getCatalog in interface java.sql.Connectionjava.sql.SQLException
public void setTransactionIsolation(int level)
throws java.sql.SQLException
setTransactionIsolation in interface java.sql.Connectionjava.sql.SQLException
public int getTransactionIsolation()
throws java.sql.SQLException
getTransactionIsolation in interface java.sql.Connectionjava.sql.SQLException
public java.sql.SQLWarning getWarnings()
throws java.sql.SQLException
getWarnings in interface java.sql.Connectionjava.sql.SQLException
public void clearWarnings()
throws java.sql.SQLException
clearWarnings in interface java.sql.Connectionjava.sql.SQLExceptionpublic boolean checkSQLError(java.lang.Exception e)
public void claim()
public void release()
public int getUsage()
public int getStartTime()
public long getStartTimeMillis()
public java.lang.String toString()
public java.sql.CallableStatement prepareCall(java.lang.String sql,
int i,
int y)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionjava.sql.SQLException
public void setTypeMap(java.util.Map mp)
throws java.sql.SQLException
setTypeMap in interface java.sql.Connectionjava.sql.SQLException
public java.util.Map getTypeMap()
throws java.sql.SQLException
getTypeMap in interface java.sql.Connectionjava.sql.SQLException
public java.sql.Statement createStatement(int i,
int y)
throws java.sql.SQLException
createStatement in interface java.sql.Connectionjava.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int i,
int y)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLException
public void setHoldability(int holdability)
throws java.sql.SQLException
setHoldability in interface java.sql.Connectionholdability - the holdability, one of ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
java.sql.SQLException
public int getHoldability()
throws java.sql.SQLException
getHoldability in interface java.sql.Connectionjava.sql.SQLException
public java.sql.Savepoint setSavepoint()
throws java.sql.SQLException
setSavepoint in interface java.sql.Connectionjava.sql.SQLException
public java.sql.Savepoint setSavepoint(java.lang.String name)
throws java.sql.SQLException
setSavepoint in interface java.sql.Connectionname - a String containing the name of the savepoint
java.sql.SQLException
public void rollback(java.sql.Savepoint savepoint)
throws java.sql.SQLException
rollback in interface java.sql.Connectionsavepoint - the Savepoint object to roll back to
java.sql.SQLException
public void releaseSavepoint(java.sql.Savepoint savepoint)
throws java.sql.SQLException
releaseSavepoint in interface java.sql.Connectionsavepoint - the Savepoint object to remove
java.sql.SQLException
public java.sql.Statement createStatement(int type,
int concurrency,
int holdability)
throws java.sql.SQLException
createStatement in interface java.sql.Connectiontype - one of the following ResultSet constants:
ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVEconcurrency - - one of the following ResultSet constants:
ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLEholdability - - one of the following ResultSet constants:
ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int type,
int concurrency,
int holdability)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionsql - a String object that is the SQL statement to be sent to the databasetype - one of the following ResultSet constants:
ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVEconcurrency - - one of the following ResultSet constants:
ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLEholdability - - one of the following ResultSet constants:
ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
java.sql.SQLException
public java.sql.CallableStatement prepareCall(java.lang.String sql,
int type,
int concurrency,
int holdability)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionsql - a String object that is the SQL statement to be sent to the databasetype - one of the following ResultSet constants:
ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVEconcurrency - - one of the following ResultSet constants:
ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLEholdability - - one of the following ResultSet constants:
ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int autoGeneratedKeys)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionsql - a String object that is the SQL statement to be sent to the databaseautoGeneratedKeys - a flag indicating whether auto-generated keys should be returned;
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int[] columnIndexes)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionsql - a String object that is the SQL statement to be sent to the databasecolumnIndexes - an array of column indexes indicating the columns that should be returned from the inserted row or rows
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
java.lang.String[] columnNames)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionsql - a String object that is the SQL statement to be sent to the databasecolumnNames - an array of column names indicating the columns that should be returned from the inserted row or rows
java.sql.SQLException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||