To add an new empty Oracle table to a database to which we can later add spatial data, we start by first creating a properties object that contains all required information.
Program: Create the properties object with the information required to create a table.
static Properties getProperties() {
Properties properties = new Properties();
// The basic database connection properties.
properties.put("driver", "oracle.jdbc.driver.OracleDriver");
properties.put("url", "jdbc:oracle:thin:@localhost:1521:XE");
properties.put("user", "luciad");
properties.put("password", "luciad");
// The data of interest.
properties.put("table", "WORLD");
properties.put("spatialColumn", "GEOM");
// The feature columns to be decoded.
properties.put("featureNames.0", "COUNTRY");
properties.put("featureNames.1", "CAPITAL");
properties.put("featureNames.2", "POP_1994");
// Optional display names.
properties.put("featureDisplayNames.0", "Country");
properties.put("featureDisplayNames.1", "Capital");
properties.put("featureDisplayNames.2", "Population");
// The index of the feature that can be used as primary key.
properties.put("primaryFeatureIndex", "0");
properties.put("SRID", "8307");
// The regular SQL data types of the feature columns.
properties.put("featureDataTypes.0", "VARCHAR2(30)");
properties.put("featureDataTypes.1", "VARCHAR2(30)");
properties.put("featureDataTypes.2", "NUMBER(10)");
// Careful with this option: it will drop the existing table (if any) when
// creating a new table (instead of failing with an SQL exception).
properties.put("dropBeforeCreatingTable", "false");
return properties;
}
We can then use this properties object to export an empty model, which creates the table.
Program: Create an empty Oracle table
TLcdOracleSpatialModelEncoder encoder = new TLcdOracleSpatialModelEncoder();
encoder.export(new TLcd2DBoundsIndexedModel(), getProperties());