|
|
|
@ -17,21 +17,167 @@
|
|
|
|
|
package com.zaxxer.hikari.proxy;
|
|
|
|
|
|
|
|
|
|
import java.sql.CallableStatement;
|
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
import java.sql.Statement;
|
|
|
|
|
|
|
|
|
|
import com.zaxxer.hikari.javassist.HikariInject;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @author Brett Wooldridge
|
|
|
|
|
*/
|
|
|
|
|
public class CallableStatementProxy extends PreparedStatementProxy
|
|
|
|
|
public class CallableStatementProxy implements IHikariStatementProxy
|
|
|
|
|
{
|
|
|
|
|
private static ProxyFactory PROXY_FACTORY;
|
|
|
|
|
|
|
|
|
|
@HikariInject private IHikariConnectionProxy _connection;
|
|
|
|
|
|
|
|
|
|
protected Statement delegate;
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
{
|
|
|
|
|
__static();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected CallableStatementProxy(ConnectionProxy connection, CallableStatement statement)
|
|
|
|
|
{
|
|
|
|
|
super(connection, statement);
|
|
|
|
|
this._connection = connection;
|
|
|
|
|
this.delegate = statement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public void setConnectionProxy(IHikariConnectionProxy connection)
|
|
|
|
|
{
|
|
|
|
|
this._connection = connection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public SQLException checkException(SQLException e)
|
|
|
|
|
{
|
|
|
|
|
return _connection.checkException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
// Overridden java.sql.CallableStatement Methods
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
|
|
|
|
|
// TODO implement wrapper
|
|
|
|
|
@HikariInject
|
|
|
|
|
public ResultSet executeQuery() throws SQLException
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery();
|
|
|
|
|
if (resultSet == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resultSet.setProxyStatement(this);
|
|
|
|
|
return (ResultSet) resultSet;
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw checkException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public void close() throws SQLException
|
|
|
|
|
{
|
|
|
|
|
_connection.unregisterStatement(this);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
__close();
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw checkException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public ResultSet executeQuery(String sql) throws SQLException
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery(sql);
|
|
|
|
|
if (resultSet == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resultSet.setProxyStatement(this);
|
|
|
|
|
return (ResultSet) resultSet;
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw checkException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public ResultSet getGeneratedKeys() throws SQLException
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __getGeneratedKeys();
|
|
|
|
|
if (resultSet == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resultSet.setProxyStatement(this);
|
|
|
|
|
return (ResultSet) resultSet;
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw checkException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***********************************************************************
|
|
|
|
|
// These methods contain code we do not want injected into the actual
|
|
|
|
|
// java.sql.Connection implementation class. These methods are only
|
|
|
|
|
// used when instrumentation is not available and "conventional" Javassist
|
|
|
|
|
// delegating proxies are used.
|
|
|
|
|
// ***********************************************************************
|
|
|
|
|
|
|
|
|
|
public ResultSet __executeQuery() throws SQLException
|
|
|
|
|
{
|
|
|
|
|
ResultSet resultSet = ((PreparedStatement) delegate).executeQuery();
|
|
|
|
|
return PROXY_FACTORY.getProxyResultSet(this, resultSet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void __static()
|
|
|
|
|
{
|
|
|
|
|
if (PROXY_FACTORY == null)
|
|
|
|
|
{
|
|
|
|
|
PROXY_FACTORY = JavassistProxyFactoryFactory.getProxyFactory();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void __close() throws SQLException
|
|
|
|
|
{
|
|
|
|
|
if (delegate.isClosed())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delegate.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ResultSet __executeQuery(String sql) throws SQLException
|
|
|
|
|
{
|
|
|
|
|
ResultSet resultSet = delegate.executeQuery(sql);
|
|
|
|
|
return PROXY_FACTORY.getProxyResultSet(this, resultSet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ResultSet __getGeneratedKeys() throws SQLException
|
|
|
|
|
{
|
|
|
|
|
ResultSet generatedKeys = delegate.getGeneratedKeys();
|
|
|
|
|
return PROXY_FACTORY.getProxyResultSet(this, generatedKeys);
|
|
|
|
|
}
|
|
|
|
|
}
|