private static void checkGeometryType(Connection connection, TableLocation tableName, int spatialFieldIndex) throws SQLException { final String fieldName = JDBCUtilities.getFieldName(connection.getMetaData(), tableName.getTable(), spatialFieldIndex); int geomType = SFSUtilities.getGeometryType(connection, tableName, fieldName); if (geomType != GeometryTypeCodes.LINESTRING) { throw new IllegalArgumentException(TYPE_ERROR + SFSUtilities.getGeometryTypeNameFromCode(geomType)); } }
private static void checkGeometryType(Connection connection, TableLocation tableName, int spatialFieldIndex) throws SQLException { final String fieldName = JDBCUtilities.getFieldName(connection.getMetaData(), tableName.getTable(), spatialFieldIndex); int geomType = SFSUtilities.getGeometryType(connection, tableName, fieldName); if (geomType != GeometryTypeCodes.LINESTRING) { throw new IllegalArgumentException(TYPE_ERROR + SFSUtilities.getGeometryTypeNameFromCode(geomType)); } }
private static void checkGeometryType(Connection connection, TableLocation tableName, int spatialFieldIndex) throws SQLException { final String fieldName = JDBCUtilities.getFieldName(connection.getMetaData(), tableName.getTable(), spatialFieldIndex); int geomType = SFSUtilities.getGeometryType(connection, tableName, fieldName); if (geomType != GeometryTypeCodes.LINESTRING) { throw new IllegalArgumentException(TYPE_ERROR + SFSUtilities.getGeometryTypeNameFromCode(geomType)); } }
@Override protected Object doInBackground() throws SQLException { try(Connection connection = dataSource.getConnection()) { boolean isH2 = JDBCUtilities.isH2DataBase(connection.getMetaData()); int columnId = JDBCUtilities.getIntegerPrimaryKey(connection, tableName); if(columnId > 0) { String pkColumnName = JDBCUtilities.getFieldName(connection.getMetaData(), tableName, columnId); // A deletion batch is an ordered set of pk values to remove (a complete serial of integer without holes) List<Long> deletionBatch = rowPkToDelete.getValueRanges(); ProgressMonitor pmBatch = getProgressMonitor().startTask(deletionBatch.size() / 2); try(PreparedStatement st = connection.prepareStatement( String.format("DELETE FROM %s WHERE %s >= ? AND %s <= ?", TableLocation.parse(tableName).toString(isH2),pkColumnName, pkColumnName))) { for (int idDelBatch = 0; idDelBatch < deletionBatch.size() - 1; idDelBatch += 2) { long startBatch = deletionBatch.get(idDelBatch); long endBatch = deletionBatch.get(idDelBatch + 1); st.setLong(1, startBatch); st.setLong(2, endBatch); st.execute(); pmBatch.endTask(); } } } } return null; }
if (pkId > 0) { return JDBCUtilities.getFieldName(connection.getMetaData(), tableLocation.toString(), pkId);
if (pkId > 0) { return JDBCUtilities.getFieldName(connection.getMetaData(), tableLocation.toString(), pkId);
String fieldName; try (Connection connection = ds.getConnection()) { fieldName = JDBCUtilities.getFieldName(connection.getMetaData(), table, columnId + 1);
String pkFieldName = TableLocation.quoteIdentifier(JDBCUtilities.getFieldName(meta, table, pkIndex)); String desc = ""; if(!ascending) {
final String pkColName = JDBCUtilities.getFieldName(md, tableName.getTable(), pkIndex); spatialFieldName = (String) spatialFieldIndexAndName[0]; checkGeometryType(connection, tableName, spatialFieldIndex); final String geomCol = JDBCUtilities.getFieldName(md, tableName.getTable(), spatialFieldIndex); final Statement st = connection.createStatement(); try {
final String pkColName = JDBCUtilities.getFieldName(md, tableName.getTable(), pkIndex); spatialFieldName = (String) spatialFieldIndexAndName[0]; checkGeometryType(connection, tableName, spatialFieldIndex); final String geomCol = JDBCUtilities.getFieldName(md, tableName.getTable(), spatialFieldIndex); final Statement st = connection.createStatement(); try {
final String pkColName = JDBCUtilities.getFieldName(md, tableName.getTable(), pkIndex); spatialFieldName = (String) spatialFieldIndexAndName[0]; checkGeometryType(connection, tableName, spatialFieldIndex); final String geomCol = JDBCUtilities.getFieldName(md, tableName.getTable(), spatialFieldIndex); final Statement st = connection.createStatement(); try {
int pkIndex = JDBCUtilities.getIntegerPrimaryKey(connection, tableLocation.toString()); DatabaseMetaData meta = connection.getMetaData(); String pkFieldName = TableLocation.quoteIdentifier(JDBCUtilities.getFieldName(meta, table, pkIndex));