@Override public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { return PreparedStatementWrapper.wrap(delegate.prepareStatement(sql, resultSetType, resultSetConcurrency), new PreparedStatementInformation(connectionInformation, sql), jdbcEventListener); }
@Override public void onAfterExecute(PreparedStatementInformation statementInformation, long timeElapsedNanos, SQLException e) { statementInformation.incrementTimeElapsed(timeElapsedNanos); }
@Override public void onAfterPreparedStatementSet(PreparedStatementInformation statementInformation, int parameterIndex, Object value, SQLException e) { statementInformation.setParameterValue(parameterIndex, value); }
public PreparedStatementInformation(final ConnectionInformation connectionInformation, String query) { super(connectionInformation); setStatementQuery(query); }
/** * Generates the query for the prepared statement with all parameter placeholders * replaced with the actual parameter values * * @return the SQL */ @Override public String getSqlWithValues() { final StringBuilder sb = new StringBuilder(); final String statementQuery = getStatementQuery(); // iterate over the characters in the query replacing the parameter placeholders // with the actual values int currentParameter = 0; for( int pos = 0; pos < statementQuery.length(); pos ++) { char character = statementQuery.charAt(pos); if( statementQuery.charAt(pos) == '?' && currentParameter <= parameterValues.size()) { // replace with parameter value Value value = parameterValues.get(currentParameter); sb.append(value != null ? value.toString() : new Value().toString()); currentParameter++; } else { sb.append(character); } } return sb.toString(); }
return super.getSqlWithValues();
public PreparedStatementInformation(final ConnectionInformation connectionInformation, String query) { super(connectionInformation); setStatementQuery(query); }
/** * Generates the query for the prepared statement with all parameter placeholders * replaced with the actual parameter values * * @return the SQL */ @Override public String getSqlWithValues() { final StringBuilder sb = new StringBuilder(); final String statementQuery = getStatementQuery(); // iterate over the characters in the query replacing the parameter placeholders // with the actual values int currentParameter = 0; for( int pos = 0; pos < statementQuery.length(); pos ++) { char character = statementQuery.charAt(pos); if( statementQuery.charAt(pos) == '?' && currentParameter <= parameterValues.size()) { // replace with parameter value Value value = parameterValues.get(currentParameter); sb.append(value != null ? value.toString() : new Value().toString()); currentParameter++; } else { sb.append(character); } } return sb.toString(); }
return super.getSqlWithValues();
@Override public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { return PreparedStatementWrapper.wrap(delegate.prepareStatement(sql, autoGeneratedKeys), new PreparedStatementInformation(connectionInformation, sql), jdbcEventListener); }
@Override public void onAfterExecuteUpdate(PreparedStatementInformation statementInformation, long timeElapsedNanos, int rowCount, SQLException e) { statementInformation.incrementTimeElapsed(timeElapsedNanos); }
@Override public void onAfterPreparedStatementSet(PreparedStatementInformation statementInformation, int parameterIndex, Object value, SQLException e) { statementInformation.setParameterValue(parameterIndex, value); }
@Override public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { return PreparedStatementWrapper.wrap(delegate.prepareStatement(sql, columnNames), new PreparedStatementInformation(connectionInformation, sql), jdbcEventListener); }
@Override public void onAfterExecuteQuery(PreparedStatementInformation statementInformation, long timeElapsedNanos, SQLException e) { statementInformation.incrementTimeElapsed(timeElapsedNanos); }
@Override public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { return PreparedStatementWrapper.wrap(delegate.prepareStatement(sql, columnIndexes), new PreparedStatementInformation(connectionInformation, sql), jdbcEventListener); }
@Override public void onAfterExecuteQuery(PreparedStatementInformation statementInformation, long timeElapsedNanos, SQLException e) { statementInformation.incrementTimeElapsed(timeElapsedNanos); }
@Override public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return PreparedStatementWrapper.wrap(delegate.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability), new PreparedStatementInformation(connectionInformation, sql), jdbcEventListener); }
@Override public void onAfterExecute(PreparedStatementInformation statementInformation, long timeElapsedNanos, SQLException e) { statementInformation.incrementTimeElapsed(timeElapsedNanos); }
@Override public PreparedStatement prepareStatement(String sql) throws SQLException { return PreparedStatementWrapper.wrap(delegate.prepareStatement(sql), new PreparedStatementInformation(connectionInformation, sql), jdbcEventListener); }
@Override public void onAfterExecuteUpdate(PreparedStatementInformation statementInformation, long timeElapsedNanos, int rowCount, SQLException e) { statementInformation.incrementTimeElapsed(timeElapsedNanos); }