use of com.alibaba.druid.proxy.jdbc.PreparedStatementProxy in project druid by alibaba.
the class FilterEventAdapter method connection_prepareStatement.
@Override
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection, String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
PreparedStatementProxy statement = super.connection_prepareStatement(chain, connection, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
statementPrepareAfter(statement);
return statement;
}
use of com.alibaba.druid.proxy.jdbc.PreparedStatementProxy in project druid by alibaba.
the class FilterEventAdapter method connection_prepareStatement.
@Override
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection, String sql, int[] columnIndexes) throws SQLException {
PreparedStatementProxy statement = super.connection_prepareStatement(chain, connection, sql, columnIndexes);
statementPrepareAfter(statement);
return statement;
}
use of com.alibaba.druid.proxy.jdbc.PreparedStatementProxy 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.PreparedStatementProxy 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.PreparedStatementProxy in project druid by alibaba.
the class DruidPooledPreparedStatementTest1 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() {
@Override
public boolean preparedStatement_execute(FilterChain chain, PreparedStatementProxy statement) throws SQLException {
throw new SQLException();
}
@Override
public int preparedStatement_executeUpdate(FilterChain chain, PreparedStatementProxy statement) throws SQLException {
throw new SQLException();
}
public ResultSetProxy preparedStatement_executeQuery(FilterChain chain, PreparedStatementProxy statement) throws SQLException {
throw new SQLException();
}
public void preparedStatement_clearParameters(FilterChain chain, PreparedStatementProxy statement) throws SQLException {
throw new SQLException();
}
@Override
public int[] statement_executeBatch(FilterChain chain, StatementProxy statement) throws SQLException {
throw new SQLException();
}
@Override
public ParameterMetaData preparedStatement_getParameterMetaData(FilterChain chain, PreparedStatementProxy statement) throws SQLException {
throw new SQLException();
}
});
}
Aggregations