use of ch.ehi.sqlgen.generator_impl.jdbc.GeneratorJdbc.Stmt in project ili2db by claeis.
the class FgdbSequenceBasedIdGen method initDbDefs.
@Override
public void initDbDefs(ch.ehi.sqlgen.generator.Generator gen) {
String sqlName = SQL_ILI2DB_SEQ_NAME;
if (schema != null) {
sqlName = schema + "." + sqlName;
}
String stmt = "CREATE SEQUENCE " + sqlName + ";";
if (gen instanceof GeneratorJdbc) {
((GeneratorJdbc) gen).addCreateLine(((GeneratorJdbc) gen).new Stmt(stmt));
((GeneratorJdbc) gen).addDropLine(((GeneratorJdbc) gen).new Stmt("DROP SEQUENCE " + sqlName + ";"));
}
try {
if (sequenceExists(new DbTableName(schema, sqlName))) {
return;
}
} catch (IOException e) {
throw new IllegalStateException(e);
}
EhiLogger.traceBackendCmd(stmt);
java.sql.PreparedStatement updstmt = null;
try {
updstmt = conn.prepareStatement(stmt);
updstmt.execute();
} catch (java.sql.SQLException ex) {
EhiLogger.logError("failed to create sequence " + sqlName, ex);
} finally {
if (updstmt != null) {
try {
updstmt.close();
} catch (java.sql.SQLException ex) {
EhiLogger.logError(ex);
}
}
}
}
use of ch.ehi.sqlgen.generator_impl.jdbc.GeneratorJdbc.Stmt in project ili2db by claeis.
the class GpkgSequenceBasedIdGen method initDbDefs.
@Override
public void initDbDefs(ch.ehi.sqlgen.generator.Generator gen) {
String sqlName = SQL_ILI2DB_SEQ_NAME;
if (schema != null) {
sqlName = schema + "." + sqlName;
}
String stmt = "CREATE SEQUENCE " + sqlName + ";";
if (gen instanceof GeneratorJdbc) {
((GeneratorJdbc) gen).addCreateLine(((GeneratorJdbc) gen).new Stmt(stmt));
((GeneratorJdbc) gen).addDropLine(((GeneratorJdbc) gen).new Stmt("DROP SEQUENCE " + sqlName + ";"));
}
try {
if (sequenceExists(new DbTableName(schema, sqlName))) {
return;
}
} catch (IOException e) {
throw new IllegalStateException(e);
}
EhiLogger.traceBackendCmd(stmt);
java.sql.PreparedStatement updstmt = null;
try {
updstmt = conn.prepareStatement(stmt);
updstmt.execute();
} catch (java.sql.SQLException ex) {
EhiLogger.logError("failed to create sequence " + sqlName, ex);
} finally {
if (updstmt != null) {
try {
updstmt.close();
} catch (java.sql.SQLException ex) {
EhiLogger.logError(ex);
}
}
}
}
Aggregations