📄 connectionwrapper.java
字号:
try {
return mc.getWarnings();
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* Passes call to method on physical connection instance. Notifies
* listeners of any caught exceptions before re-throwing to client.
*
* @throws SQLException if an error occurs
*/
public void clearWarnings() throws SQLException {
if (closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
mc.clearWarnings();
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
}
/**
* The physical connection is not actually closed. the physical connection
* is closed when the application server calls
* mysqlPooledConnection.close(). this object is de-referenced by the
* pooled connection each time mysqlPooledConnection.getConnection() is
* called by app server.
*
* @throws SQLException if an error occurs
*/
public void close() throws SQLException {
close(true);
}
/**
* Passes call to method on physical connection instance. Notifies
* listeners of any caught exceptions before re-throwing to client.
*
* @throws SQLException if an error occurs
*/
public void commit() throws SQLException {
if (closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
mc.commit();
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
}
/**
* Passes call to method on physical connection instance. Notifies
* listeners of any caught exceptions before re-throwing to client.
*
* @see java.sql.Connection#createStatement()
*/
public java.sql.Statement createStatement() throws SQLException {
if (this.closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return new StatementWrapper(this.mpc, mc.createStatement());
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* Passes call to method on physical connection instance. Notifies
* listeners of any caught exceptions before re-throwing to client.
*
* @see java.sql.Connection#createStatement()
*/
public java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency) throws SQLException {
if (this.closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return new StatementWrapper(this.mpc, mc.createStatement(resultSetType, resultSetConcurrency));
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* @see Connection#createStatement(int, int, int)
*/
public java.sql.Statement createStatement(int arg0, int arg1, int arg2)
throws SQLException {
if (this.closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return new StatementWrapper(this.mpc, mc.createStatement(arg0, arg1, arg2));
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* Passes call to method on physical connection instance. Notifies
* listeners of any caught exceptions before re-throwing to client.
*
* @see java.sql.Connection#nativeSQL()
*/
public String nativeSQL(String sql) throws SQLException {
if (closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return mc.nativeSQL(sql);
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* Passes call to method on physical connection instance. Notifies
* listeners of any caught exceptions before re-throwing to client.
*
* @see java.sql.Connection#prepareCall()
*/
public java.sql.CallableStatement prepareCall(String sql)
throws SQLException {
if (closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return mc.prepareCall(sql);
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* Passes call to method on physical connection instance. Notifies
* listeners of any caught exceptions before re-throwing to client.
*
* @see java.sql.Connection#prepareCall()
*/
public java.sql.CallableStatement prepareCall(String sql,
int resultSetType, int resultSetConcurrency) throws SQLException {
if (closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return mc.prepareCall(sql, resultSetType, resultSetConcurrency);
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* @see Connection#prepareCall(String, int, int, int)
*/
public java.sql.CallableStatement prepareCall(String arg0, int arg1,
int arg2, int arg3) throws SQLException {
if (closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return mc.prepareCall(arg0, arg1, arg2, arg3);
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* Passes call to method on physical connection instance. Notifies
* listeners of any caught exceptions before re-throwing to client.
*
* @see java.sql.Connection#prepareStatement()
*/
public java.sql.PreparedStatement prepareStatement(String sql)
throws SQLException {
if (this.closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return new PreparedStatementWrapper(this.mpc, mc.prepareStatement(sql));
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* Passes call to method on physical connection instance. Notifies
* listeners of any caught exceptions before re-throwing to client.
*
* @see java.sql.Connection#prepareStatement()
*/
public java.sql.PreparedStatement prepareStatement(String sql,
int resultSetType, int resultSetConcurrency) throws SQLException {
if (this.closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return new PreparedStatementWrapper(this.mpc, mc.prepareStatement(sql, resultSetType,
resultSetConcurrency));
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* @see Connection#prepareStatement(String, int, int, int)
*/
public java.sql.PreparedStatement prepareStatement(String arg0, int arg1,
int arg2, int arg3) throws SQLException {
if (this.closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return new PreparedStatementWrapper(this.mpc, mc.prepareStatement(arg0, arg1, arg2, arg3));
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* @see Connection#prepareStatement(String, int)
*/
public java.sql.PreparedStatement prepareStatement(String arg0, int arg1)
throws SQLException {
if (this.closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return new PreparedStatementWrapper(this.mpc, mc.prepareStatement(arg0, arg1));
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* @see Connection#prepareStatement(String, int[])
*/
public java.sql.PreparedStatement prepareStatement(String arg0, int[] arg1)
throws SQLException {
if (this.closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return new PreparedStatementWrapper(this.mpc, mc.prepareStatement(arg0, arg1));
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* @see Connection#prepareStatement(String, String[])
*/
public java.sql.PreparedStatement prepareStatement(String arg0,
String[] arg1) throws SQLException {
if (this.closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
return new PreparedStatementWrapper(this.mpc, mc.prepareStatement(arg0, arg1));
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
return null; // we don't reach this code, compiler can't tell
}
/**
* @see Connection#releaseSavepoint(Savepoint)
*/
public void releaseSavepoint(Savepoint arg0) throws SQLException {
if (closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
mc.releaseSavepoint(arg0);
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
}
/**
* Passes call to method on physical connection instance. Notifies
* listeners of any caught exceptions before re-throwing to client.
*
* @see java.sql.Connection#rollback()
*/
public void rollback() throws SQLException {
if (closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
mc.rollback();
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
}
/**
* @see Connection#rollback(Savepoint)
*/
public void rollback(Savepoint arg0) throws SQLException {
if (closed) {
throw new SQLException(invalidHandleStr);
} else {
try {
mc.rollback(arg0);
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
}
}
protected void close(boolean fireClosedEvent)
throws SQLException {
synchronized (this.mpc) {
if (closed) {
return;
}
if (fireClosedEvent) {
mpc.callListener(MysqlPooledConnection.CONNECTION_CLOSED_EVENT, null);
}
// set closed status to true so that if application client tries to make additional
// calls a sqlException will be thrown. The physical connection is
// re-used by the pooled connection each time getConnection is called.
this.closed = true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -