public static PreparedStatementBuilder prepare(PreparedStatement st) throws SQLException { return new PreparedStatementBuilder(st); } }
public PreparedStatementBuilder set(String s) throws SQLException { log(s); ps.setString(pos++, s); return this; }
static void runScript(String filename, Connection cx) throws SQLException { SqlUtil.runScript(GeoPackage.class.getResourceAsStream(filename), cx); }
protected void saveMetaDataEntry(String name, String value, Connection cx) throws SQLException { PreparedStatement ps; if (disableJournal) { disableJournal(cx); } if (value != null) { ps = prepare(cx, format("INSERT OR REPLACE INTO %s VALUES (?,?)", TABLE_METADATA)) .set(name) .set(value) .log(Level.FINE) .statement(); } else { ps = prepare(cx, format("DELETE FROM %s WHERE NAME = ?", TABLE_METADATA)) .set(name) .log(Level.FINE) .statement(); } ps.execute(); ps.close(); }
public TileIterator tiles( long zoomLevel, long leftTile, long bottomTile, long rightTile, long topTile) throws SQLException { Connection cx = connPool.getConnection(); PreparedStatement ps = prepare( cx, format( "SELECT * FROM %s WHERE zoom_level=? AND tile_column >= ? AND tile_row >= ? AND tile_column <= ? AND tile_row <= ?", TABLE_TILES)) .set(zoomLevel) .set(leftTile) .set(bottomTile) .set(rightTile) .set(topTile) .statement(); return new TileIterator(ps.executeQuery()); }
protected String loadMetaDataEntry(String name, Connection cx) throws SQLException { PreparedStatement ps; ps = prepare(cx, format("SELECT VALUE FROM %s WHERE NAME = ?", TABLE_METADATA)) .set(name) .log(Level.FINE) .statement(); ResultSet rs = ps.executeQuery(); String result = null; if (rs.next()) { result = rs.getString(1); } rs.close(); ps.close(); return result; }
public PreparedStatementBuilder set(Boolean b) throws SQLException { log(b); ps.setBoolean(pos++, b); return this; }
void runScript(String filename, Connection cx, Map<String, String> properties) throws SQLException { SqlUtil.runScript(getClass().getResourceAsStream(filename), cx, properties); }
public static PreparedStatementBuilder prepare(Connection conn, String sql) throws SQLException { return new PreparedStatementBuilder(conn, sql); }
void deleteGeoPackageContentsEntry(Entry e) throws IOException { String sql = format("DELETE FROM %s WHERE table_name = ?", GEOPACKAGE_CONTENTS); try { Connection cx = connPool.getConnection(); try { PreparedStatement ps = prepare(cx, sql).set(e.getTableName()).log(Level.FINE).statement(); try { ps.execute(); } finally { close(ps); } } finally { close(cx); } } catch (SQLException ex) { throw new IOException(ex); } }
public long minColumn(long zoomLevel) throws SQLException { long size = 0; Connection cx = connPool.getConnection(); try { PreparedStatement ps = prepare( cx, format( "SELECT MIN(tile_column) FROM %s WHERE zoom_level=?", TABLE_TILES)) .set(zoomLevel) .statement(); ResultSet rs = ps.executeQuery(); if (rs.next()) { size = rs.getLong(1); } rs.close(); ps.close(); } finally { cx.close(); } return size; }
public PreparedStatementBuilder set(Long l) throws SQLException { log(l); ps.setLong(pos++, l); return this; }
protected void runScript(String filename, Connection cx) throws SQLException { SqlUtil.runScript(getClass().getResourceAsStream(filename), cx); }
public long maxColumn(long zoomLevel) throws SQLException { long size = Long.MAX_VALUE; Connection cx = connPool.getConnection(); try { PreparedStatement ps = prepare( cx, format( "SELECT MAX(tile_column) FROM %s WHERE zoom_level=?", TABLE_TILES)) .set(zoomLevel) .statement(); ResultSet rs = ps.executeQuery(); if (rs.next()) { size = rs.getLong(1); } rs.close(); ps.close(); } finally { cx.close(); } return size; }
public PreparedStatementBuilder set(byte[] b) throws SQLException { log(b); ps.setBytes(pos++, b); // ps.setBinaryStream(pos++, is); return this; }
public PreparedStatementBuilder set(Double d) throws SQLException { log(d); if (d != null) { ps.setDouble(pos++, d); } else { ps.setNull(pos++, Types.DOUBLE); } return this; }
public PreparedStatementBuilder set(Integer i) throws SQLException { log(i); if (i != null) { ps.setInt(pos++, i); } else { ps.setNull(pos++, Types.INTEGER); } return this; }
public PreparedStatementBuilder set(Date d) throws SQLException { log(d); ps.setDate(pos++, d != null ? new java.sql.Date(d.getTime()) : null); return this; }