public final class SimonConnection extends java.lang.Object implements java.sql.Connection
Every method of this connection is implemented as call of real connection method. Several methods have added work with Simons (starting, stopping, etc.) for monitoring purposes.
From all statement-return-methods (createStatement(*)
,
prepareStatement(*)
, prepareCall(*)
) connection returns own
implementation of statement classes. Those classes are also proxies and provides
additional Simons for monitoring features of JDBC driver.
org.javasimon.jdbc4.conn
, stopwatch) - measure connection life and countorg.javasimon.jdbc4.conn.commits
, counter) - measure executed commits of all connectionsorg.javasimon.jdbc4.conn.rollbacks
, counter) - measure executed rollbacks of all connectionsConnection
Constructor and Description |
---|
SimonConnection(java.sql.Connection conn,
java.lang.String prefix)
Class constructor, initializes Simons (lifespan, active, commits
and rollbacks) related to the DB connection.
|
Modifier and Type | Method and Description |
---|---|
void |
abort(java.util.concurrent.Executor executor) |
void |
clearWarnings() |
void |
close()
Closes the real connection, stops lifespan Simon and decreases the active Simon.
|
void |
commit()
Commits the real connection and increases the commits Simon.
|
java.sql.Array |
createArrayOf(java.lang.String s,
java.lang.Object[] objects) |
java.sql.Blob |
createBlob() |
java.sql.Clob |
createClob() |
java.sql.NClob |
createNClob() |
java.sql.SQLXML |
createSQLXML() |
java.sql.Statement |
createStatement()
Calls the real createStatement and wraps the returned statement by Simon's statement.
|
java.sql.Statement |
createStatement(int rsType,
int rsConcurrency)
Calls real createStatement and wraps returned statement by Simon's statement.
|
java.sql.Statement |
createStatement(int rsType,
int rsConcurrency,
int rsHoldability)
Calls real createStatement and wraps returned statement by Simon's statement.
|
java.sql.Struct |
createStruct(java.lang.String s,
java.lang.Object[] objects) |
boolean |
getAutoCommit() |
java.lang.String |
getCatalog() |
java.util.Properties |
getClientInfo() |
java.lang.String |
getClientInfo(java.lang.String s) |
int |
getHoldability() |
java.sql.DatabaseMetaData |
getMetaData() |
int |
getNetworkTimeout() |
java.lang.String |
getSchema() |
int |
getTransactionIsolation() |
java.util.Map<java.lang.String,java.lang.Class<?>> |
getTypeMap() |
java.sql.SQLWarning |
getWarnings() |
boolean |
isClosed() |
boolean |
isReadOnly() |
boolean |
isValid(int i) |
boolean |
isWrapperFor(java.lang.Class<?> iface) |
java.lang.String |
nativeSQL(java.lang.String s) |
java.sql.CallableStatement |
prepareCall(java.lang.String sql)
Calls real prepareCall and wraps returned statement by Simon's statement.
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int rsType,
int rsConcurrency)
Calls real prepareCall and wraps returned statement by Simon's statement.
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int rsType,
int rsConcurrency,
int rsHoldability)
Calls real prepareCall and wraps returned statement by Simon's statement.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
Calls real prepareStatement and wraps returned statement by Simon's statement.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int autoGeneratedKeys)
Calls real prepareStatement and wraps returned statement by Simon's statement.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int[] columnIndexes)
Calls real prepareStatement and wraps returned statement by Simon's statement.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int rsType,
int rsConcurrency)
Calls real prepareStatement and wraps returned statement by Simon's statement.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int rsType,
int rsConcurrency,
int rsHoldability)
Calls real prepareStatement and wraps returned statement by Simon's statement.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.String[] columnNames)
Calls real prepareStatement and wraps returned statement by Simon's statement.
|
void |
releaseSavepoint(java.sql.Savepoint savepoint) |
void |
rollback()
Rollback the real connection and increase the rollbacks Simon.
|
void |
rollback(java.sql.Savepoint savepoint)
Rollbacks the real connection and increases the rollbacks Simon.
|
void |
setAutoCommit(boolean b) |
void |
setCatalog(java.lang.String s) |
void |
setClientInfo(java.util.Properties properties) |
void |
setClientInfo(java.lang.String s,
java.lang.String s1) |
void |
setHoldability(int i) |
void |
setNetworkTimeout(java.util.concurrent.Executor executor,
int milliseconds) |
void |
setReadOnly(boolean b) |
java.sql.Savepoint |
setSavepoint() |
java.sql.Savepoint |
setSavepoint(java.lang.String s) |
void |
setSchema(java.lang.String schema) |
void |
setTransactionIsolation(int i) |
void |
setTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> stringClassMap) |
<T> T |
unwrap(java.lang.Class<T> iface) |
public SimonConnection(java.sql.Connection conn, java.lang.String prefix)
conn
- real DB connectionprefix
- hierarchy prefix for connection Simonspublic void close() throws java.sql.SQLException
close
in interface java.lang.AutoCloseable
close
in interface java.sql.Connection
java.sql.SQLException
- if real operation failspublic void commit() throws java.sql.SQLException
commit
in interface java.sql.Connection
java.sql.SQLException
- if real commit failspublic void rollback() throws java.sql.SQLException
rollback
in interface java.sql.Connection
java.sql.SQLException
- if real operation failspublic void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLException
rollback
in interface java.sql.Connection
savepoint
- the Savepoint
object to roll back tojava.sql.SQLException
- if real operation failspublic java.sql.Statement createStatement() throws java.sql.SQLException
createStatement
in interface java.sql.Connection
java.sql.SQLException
- if real operation failspublic java.sql.Statement createStatement(int rsType, int rsConcurrency) throws java.sql.SQLException
createStatement
in interface java.sql.Connection
rsType
- result set typersConcurrency
- result set concurrencyjava.sql.SQLException
- if real operation failspublic java.sql.Statement createStatement(int rsType, int rsConcurrency, int rsHoldability) throws java.sql.SQLException
createStatement
in interface java.sql.Connection
rsType
- result set typersConcurrency
- result set concurrencyrsHoldability
- result set holdabilityjava.sql.SQLException
- if real operation failspublic java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
sql
- SQL statementjava.sql.SQLException
- if real operation failspublic java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
sql
- SQL statementautoGeneratedKeys
- auto generated keysjava.sql.SQLException
- if real operation failspublic java.sql.PreparedStatement prepareStatement(java.lang.String sql, int rsType, int rsConcurrency) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
sql
- SQL statementrsType
- result set typersConcurrency
- result set concurrencyjava.sql.SQLException
- if real operation failspublic java.sql.PreparedStatement prepareStatement(java.lang.String sql, int rsType, int rsConcurrency, int rsHoldability) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
sql
- SQL statementrsType
- result set typersConcurrency
- result set concurrencyrsHoldability
- result set holdabilityjava.sql.SQLException
- if real operation failspublic java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
sql
- SQL statementcolumnIndexes
- an array of column indexes indicating the columns
that should be returned from the inserted row or rowsjava.sql.SQLException
- if real operation failspublic java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
sql
- SQL statementcolumnNames
- an array of column names indicating the columns
that should be returned from the inserted row or rowsjava.sql.SQLException
- if real operation failspublic java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
sql
- an SQL statement, typically a JDBC function call escape stringjava.sql.SQLException
- if real operation failspublic java.sql.CallableStatement prepareCall(java.lang.String sql, int rsType, int rsConcurrency) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
sql
- an SQL statement, typically a JDBC function call escape stringrsType
- result set typersConcurrency
- result set concurrencyjava.sql.SQLException
- if real operation failspublic java.sql.CallableStatement prepareCall(java.lang.String sql, int rsType, int rsConcurrency, int rsHoldability) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
sql
- an SQL statement, typically a JDBC function call escape stringrsType
- result set typersConcurrency
- result set concurrencyrsHoldability
- result set holdabilityjava.sql.SQLException
- if real operation failspublic java.lang.String nativeSQL(java.lang.String s) throws java.sql.SQLException
nativeSQL
in interface java.sql.Connection
java.sql.SQLException
public void setAutoCommit(boolean b) throws java.sql.SQLException
setAutoCommit
in interface java.sql.Connection
java.sql.SQLException
public boolean getAutoCommit() throws java.sql.SQLException
getAutoCommit
in interface java.sql.Connection
java.sql.SQLException
public boolean isClosed() throws java.sql.SQLException
isClosed
in interface java.sql.Connection
java.sql.SQLException
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
getMetaData
in interface java.sql.Connection
java.sql.SQLException
public void setReadOnly(boolean b) throws java.sql.SQLException
setReadOnly
in interface java.sql.Connection
java.sql.SQLException
public boolean isReadOnly() throws java.sql.SQLException
isReadOnly
in interface java.sql.Connection
java.sql.SQLException
public void setCatalog(java.lang.String s) throws java.sql.SQLException
setCatalog
in interface java.sql.Connection
java.sql.SQLException
public java.lang.String getCatalog() throws java.sql.SQLException
getCatalog
in interface java.sql.Connection
java.sql.SQLException
public void setTransactionIsolation(int i) throws java.sql.SQLException
setTransactionIsolation
in interface java.sql.Connection
java.sql.SQLException
public int getTransactionIsolation() throws java.sql.SQLException
getTransactionIsolation
in interface java.sql.Connection
java.sql.SQLException
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException
getWarnings
in interface java.sql.Connection
java.sql.SQLException
public void clearWarnings() throws java.sql.SQLException
clearWarnings
in interface java.sql.Connection
java.sql.SQLException
public java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap() throws java.sql.SQLException
getTypeMap
in interface java.sql.Connection
java.sql.SQLException
public void setTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> stringClassMap) throws java.sql.SQLException
setTypeMap
in interface java.sql.Connection
java.sql.SQLException
public void setHoldability(int i) throws java.sql.SQLException
setHoldability
in interface java.sql.Connection
java.sql.SQLException
public int getHoldability() throws java.sql.SQLException
getHoldability
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Savepoint setSavepoint() throws java.sql.SQLException
setSavepoint
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Savepoint setSavepoint(java.lang.String s) throws java.sql.SQLException
setSavepoint
in interface java.sql.Connection
java.sql.SQLException
public void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLException
releaseSavepoint
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Clob createClob() throws java.sql.SQLException
createClob
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Blob createBlob() throws java.sql.SQLException
createBlob
in interface java.sql.Connection
java.sql.SQLException
public java.sql.NClob createNClob() throws java.sql.SQLException
createNClob
in interface java.sql.Connection
java.sql.SQLException
public java.sql.SQLXML createSQLXML() throws java.sql.SQLException
createSQLXML
in interface java.sql.Connection
java.sql.SQLException
public boolean isValid(int i) throws java.sql.SQLException
isValid
in interface java.sql.Connection
java.sql.SQLException
public void setClientInfo(java.lang.String s, java.lang.String s1) throws java.sql.SQLClientInfoException
setClientInfo
in interface java.sql.Connection
java.sql.SQLClientInfoException
public void setClientInfo(java.util.Properties properties) throws java.sql.SQLClientInfoException
setClientInfo
in interface java.sql.Connection
java.sql.SQLClientInfoException
public java.lang.String getClientInfo(java.lang.String s) throws java.sql.SQLException
getClientInfo
in interface java.sql.Connection
java.sql.SQLException
public java.util.Properties getClientInfo() throws java.sql.SQLException
getClientInfo
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Array createArrayOf(java.lang.String s, java.lang.Object[] objects) throws java.sql.SQLException
createArrayOf
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Struct createStruct(java.lang.String s, java.lang.Object[] objects) throws java.sql.SQLException
createStruct
in interface java.sql.Connection
java.sql.SQLException
public void setSchema(java.lang.String schema) throws java.sql.SQLException
setSchema
in interface java.sql.Connection
java.sql.SQLException
public java.lang.String getSchema() throws java.sql.SQLException
getSchema
in interface java.sql.Connection
java.sql.SQLException
public void abort(java.util.concurrent.Executor executor) throws java.sql.SQLException
abort
in interface java.sql.Connection
java.sql.SQLException
public void setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds) throws java.sql.SQLException
setNetworkTimeout
in interface java.sql.Connection
java.sql.SQLException
public int getNetworkTimeout() throws java.sql.SQLException
getNetworkTimeout
in interface java.sql.Connection
java.sql.SQLException
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
unwrap
in interface java.sql.Wrapper
java.sql.SQLException
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
isWrapperFor
in interface java.sql.Wrapper
java.sql.SQLException
Copyright © 2018. All Rights Reserved.