public <T> ISqlReadCursor<T> queryForCursor(String sql, ISqlRowMapper<T> mapper, Object[] args, int[] types) { logSql(sql, args); return new JdbcSqlReadCursor<T>(this, mapper, sql, args, types); }
public <T> List<T> query(String sql, ISqlRowMapper<T> mapper, Map<String, Object> namedParams) { ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql); String newSql = NamedParameterUtils.substituteNamedParameters(parsedSql, namedParams); Object[] params = NamedParameterUtils.buildValueArray(parsedSql, namedParams); return query(newSql, mapper, params, null); }
public T next() { try { while (rs!=null && rs.next()) { Row row = getMapForRow(rs, sqlTemplate.getSettings().isReadStringsAsBytes()); T value = mapper.mapRow(row); if (value != null) { return value; } } return null; } catch (SQLException ex) { throw sqlTemplate.translate(ex); } }
public <T> T execute(IConnectionCallback<T> callback) { Connection c = null; try { c = getConnection(); return callback.execute(c); } catch (SQLException ex) { throw translate(ex); } finally { close(c); } }
public int update(boolean autoCommit, boolean failOnError, int commitRate, ISqlResultsListener resultsListener, String... sql) { return this.update(autoCommit, failOnError, true, true, commitRate, resultsListener, new ListSqlStatementSource(sql)); }
public void close() { JdbcSqlTemplate.close(rs); JdbcSqlTemplate.close(st); JdbcSqlTemplate.close(autoCommitFlag, originalIsolationLevel, c); SqlUtils.removeSqlReadCursor(this); } }
private long[] queryForMinMax(String sql, Object... params) { long[] minMax = sqlTemplate.queryForObject(sql, new ISqlRowMapper<long[]>() { public long[] mapRow(Row rs) { return new long[] { rs.getLong("min_id"), rs.getLong("max_id") }; } }, params); return minMax; }
public long insertWithGeneratedKey(String sql, String column, String sequenceName, Object[] args, int[] types) { try { return jdbcSqlTemplate.insertWithGeneratedKey(connection, sql, column, sequenceName, args, types); } catch (SQLException ex) { throw jdbcSqlTemplate.translate(ex); } }
protected void closeCursor() { if (this.cursor != null) { this.cursor.close(); this.cursor = null; } }
public void testConnection() { execute(new IConnectionCallback<Boolean>() { public Boolean execute(Connection con) throws SQLException { return true; } }); }
public Long execute(Connection conn) throws SQLException { return insertWithGeneratedKey(conn, sql, column, sequenceName, args, types); } });
public void setValues(PreparedStatement ps, Object[] args) throws SQLException { if (args != null) { for (int i = 0; i < args.length; i++) { Object arg = args[i]; doSetValue(ps, i + 1, arg); } } }
public long queryForLong(String sql, Object... args) { Long val = queryForObject(sql, Long.class, args); if (val == null) { val = Long.MIN_VALUE; } return val; }
public boolean isStoresUpperCaseIdentifiers() { return execute(new IConnectionCallback<Boolean>() { public Boolean execute(Connection con) throws SQLException { return con.getMetaData().storesUpperCaseIdentifiers(); } }); }
public String getDatabaseProductName() { return execute(new IConnectionCallback<String>() { public String execute(Connection con) throws SQLException { return con.getMetaData().getDatabaseProductName(); } }); }
public String getDatabaseProductVersion() { return execute(new IConnectionCallback<String>() { public String execute(Connection con) throws SQLException { return con.getMetaData().getDatabaseProductVersion(); } }); }
public String getDriverName() { return execute(new IConnectionCallback<String>() { public String execute(Connection con) throws SQLException { return con.getMetaData().getDriverName(); } }); }
public boolean isStoresMixedCaseQuotedIdentifiers() { return execute(new IConnectionCallback<Boolean>() { public Boolean execute(Connection con) throws SQLException { return con.getMetaData().storesMixedCaseQuotedIdentifiers(); } }); }