use of com.alibaba.druid.proxy.jdbc.CallableStatementProxy in project druid by alibaba.
the class PreparedStatementPool method put.
public void put(PreparedStatementHolder stmtHolder) throws SQLException {
PreparedStatement stmt = stmtHolder.statement;
if (stmt == null) {
return;
}
if (dataSource.isOracle() && dataSource.isUseOracleImplicitCache()) {
OracleUtils.enterImplicitCache(stmt);
stmtHolder.setEnterOracleImplicitCache(true);
} else {
stmtHolder.setEnterOracleImplicitCache(false);
}
PreparedStatementHolder oldStmtHolder = map.put(stmtHolder.key, stmtHolder);
if (oldStmtHolder == stmtHolder) {
return;
}
if (oldStmtHolder != null) {
oldStmtHolder.setPooling(false);
closeRemovedStatement(oldStmtHolder);
} else {
if (stmtHolder.getHitCount() == 0) {
dataSource.incrementCachedPreparedStatementCount();
}
}
stmtHolder.setPooling(true);
if (LOG.isDebugEnabled()) {
String message = null;
if (stmtHolder.statement instanceof PreparedStatementProxy) {
PreparedStatementProxy stmtProxy = (PreparedStatementProxy) stmtHolder.statement;
if (stmtProxy instanceof CallableStatementProxy) {
message = "{conn-" + stmtProxy.getConnectionProxy().getId() + ", cstmt-" + stmtProxy.getId() + "} enter cache";
} else {
message = "{conn-" + stmtProxy.getConnectionProxy().getId() + ", pstmt-" + stmtProxy.getId() + "} enter cache";
}
} else {
message = "stmt enter cache";
}
LOG.debug(message);
}
}
use of com.alibaba.druid.proxy.jdbc.CallableStatementProxy in project druid by alibaba.
the class WallFilter method connection_prepareCall.
@Override
public CallableStatementProxy connection_prepareCall(FilterChain chain, ConnectionProxy connection, String sql) throws SQLException {
String dbType = connection.getDirectDataSource().getDbType();
WallContext.create(dbType);
try {
sql = check(sql);
CallableStatementProxy stmt = chain.connection_prepareCall(connection, sql);
setSqlStatAttribute(stmt);
return stmt;
} finally {
WallContext.clearContext();
}
}
use of com.alibaba.druid.proxy.jdbc.CallableStatementProxy in project druid by alibaba.
the class DruidPooledCallableStatementTest method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setInitialSize(1);
dataSource.getProxyFilters().add(new FilterAdapter() {
public boolean callableStatement_wasNull(FilterChain chain, CallableStatementProxy statement) throws SQLException {
if (throwError) {
throw new SQLException();
} else {
return chain.callableStatement_wasNull(statement);
}
}
});
}
use of com.alibaba.druid.proxy.jdbc.CallableStatementProxy in project druid by alibaba.
the class DruidPooledConnectionTest_prepareError method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setFilters("stat");
dataSource.setPoolPreparedStatements(true);
dataSource.getProxyFilters().add(new FilterAdapter() {
@Override
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection, String sql) throws SQLException {
throw new SQLException();
}
@Override
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection, String sql, int autoGeneratedKeys) throws SQLException {
throw new SQLException();
}
@Override
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection, String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
throw new SQLException();
}
@Override
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection, String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
throw new SQLException();
}
@Override
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection, String sql, int[] columnIndexes) throws SQLException {
throw new SQLException();
}
@Override
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection, String sql, String[] columnNames) throws SQLException {
throw new SQLException();
}
@Override
public CallableStatementProxy connection_prepareCall(FilterChain chain, ConnectionProxy connection, String sql) throws SQLException {
throw new SQLException();
}
@Override
public CallableStatementProxy connection_prepareCall(FilterChain chain, ConnectionProxy connection, String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
throw new SQLException();
}
@Override
public CallableStatementProxy connection_prepareCall(FilterChain chain, ConnectionProxy connection, String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
throw new SQLException();
}
});
}
use of com.alibaba.druid.proxy.jdbc.CallableStatementProxy in project druid by alibaba.
the class FilterEventAdapter method connection_prepareCall.
@Override
public CallableStatementProxy connection_prepareCall(FilterChain chain, ConnectionProxy connection, String sql) throws SQLException {
CallableStatementProxy statement = super.connection_prepareCall(chain, connection, sql);
statementPrepareCallAfter(statement);
return statement;
}
Aggregations