Geometry is not a standard JDBC type, and is fairly non-standard across databases. Hence it must be handled specially, by using conversion functions in JEQL and/or in the DB query. Geometry values can often be read as WKT or hex-encoded WKB. It is often possible to write geometry from JEQL to a database by providing it as WKT or hex-encoded WKB, and using a suitable conversion function on the database side in the INSERT statement.
Example:
driver: "org.h2.Driver"
Example:
url: "jdbc:h2:tcp://localhost/~/test"
url: "jdbc:sqlite:sample.db"
If not specified, "?,?,?,..." is used.
Example:
values: "?, ?, ?"
values: "?, ?, ST_GeometryFromText(?, 3005)"
If values: is specified, table: must also be provided.
Example:
sql: "INSERT INTO test (id, name, value) VALUES (?, ?, ?)"
sql: "INSERT INTO tbl-name (id, name, geom) VALUES (?, ?, ST_GeometryFromText(?, 3005) ) "
dbClass = "org.sqlite.JDBC"; dbUrl = "jdbc:sqlite:sample.db"; DbExec driver: dbClass url: dbUrl sql: $"CREATE TABLE TEST (ID INTEGER NOT NULL, NAME VARCHAR(25) ) "; tin = select i ID, "first_" + i + "_" + Date.now() NAME from Generate.sequence(1, 10); DbWriter tin driver: dbClass url: dbUrl table: "TEST" batchSize: 2 commitSize: 0; DbReader tcnt driver: dbClass url: dbUrl sql: "SELECT count(*) FROM TEST;" ; Print "# rows in table is " + Val(tcnt); DbReader tout driver: dbClass url: dbUrl sql: "SELECT * FROM TEST;" ; Print tout; DbExec driver: dbClass url: dbUrl sql: "DROP TABLE TEST;" ; |