private void mutedClose(Connection connection, PreparedStatement statement, ResultSet resultSet) { try { resultSet.close(); statement.close(); connection.close(); } catch (SQLException e) { LOGGER.info("Exception thrown " + e.getMessage()); } }
/** * Constructor used to initialize with provided database meta-data. * @param databaseMetaData meta-data to be used */ protected GenericCallMetaDataProvider(DatabaseMetaData databaseMetaData) throws SQLException { this.userName = databaseMetaData.getUserName(); }
@Override public void setBlobAsBytes(PreparedStatement ps, int paramIndex, byte[] content) throws SQLException { Blob blob = ps.getConnection().createBlob(); blob.setBytes(1, content); ps.setBlob(paramIndex, blob); }
@Override public String doInConnection(Connection con) throws SQLException { PreparedStatement ps = con.prepareStatement("some SQL"); ps.setFetchSize(10); ps.setMaxRows(20); ps.close(); return "test"; } });
@Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement(this.sql); ps.setInt(1, this.id); return ps; }
@Override protected Integer mapRow(ResultSet rs, int rownum) throws SQLException { return rs.getInt(1); } };
@Override public String mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getString(2); } }
@Override protected boolean setValuesIfAvailable(PreparedStatement ps, int i) throws SQLException { if (i < ids.length) { ps.setInt(1, ids[i]); return true; } else { return false; } } };
/** * Getting a Connection using the nasty static from DriverManager is extracted * into a protected method to allow for easy unit testing. * @see java.sql.DriverManager#getConnection(String, java.util.Properties) */ protected Connection getConnectionFromDriverManager(String url, Properties props) throws SQLException { return DriverManager.getConnection(url, props); }
/** * Constructor for InvalidResultSetAccessException. * @param ex the root cause */ public InvalidResultSetAccessException(SQLException ex) { super(ex.getMessage(), ex); this.sql = null; }
@Override protected void provideXml(SQLXML xmlObject) throws SQLException, IOException { xmlObject.setString(value); } };
@Override public Integer mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getInt(1); } });
@Override protected boolean setValuesIfAvailable(PreparedStatement ps, int i) throws SQLException { if (i < ids.length) { ps.setInt(1, ids[i]); return true; } else { return false; } } };
/** * Constructor for InvalidResultSetAccessException. * @param msg message * @param ex the root cause */ public InvalidResultSetAccessException(String msg, SQLException ex) { super(ex.getMessage(), ex); }
/** * Constructor used to initialize with provided database meta-data. * @param databaseMetaData meta-data to be used */ protected GenericTableMetaDataProvider(DatabaseMetaData databaseMetaData) throws SQLException { this.userName = databaseMetaData.getUserName(); }
@Override protected Integer mapRow(ResultSet rs, int rownum) throws SQLException { return rs.getInt(1); } };
@Override public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setInt(1, ids[i]); } @Override
@Override public Integer mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getInt(1); } });
@Override public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setInt(1, ids[i]); } @Override
@Override public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setInt(1, ids[i]); } @Override