1
votes

I am using liquibase to generate the changeLog.xml for a pre-existing derby database.

liquibase --logLevel=debug --driver=org.apache.derby.jdbc.EmbeddedDriver
--classpath=/xxx/derby.jar --changeLogFile=/xxx/TestDb/db.changelog2.xml
--url="jdbc:derby:/xxx/TestDb/yyyy.db" --username= --password= generateChangeLog

A sql syntax error ERROR 42X01: Syntax error: Encountered "CONSTRAINTS" at line 1, column 8 was reported by liquibase.

Can some one provide any pointers to resolve this issue?

Below is the error log:

Liquibase Home is not set. Liquibase Home: /xxx/liquibase DEBUG 1/9/13 5:40 PM:liquibase: Unable to load/access Apache Derby driver class to check version DEBUG 1/9/13 5:40 PM:liquibase: Unable to load/access Apache Derby driver class to check version DEBUG 1/9/13 5:40 PM:liquibase: Connected to APP@jdbc:derby:/xxx/TestDb/yyyy.db DEBUG 1/9/13 5:40 PM:liquibase: Reading tables for APP @ jdbc:derby:/xxx/TestDb/yyyy.db ... INFO 1/9/13 5:40 PM:liquibase: Reading tables for APP @ jdbc:derby:/xxx/TestDb/yyyy.db ... DEBUG 1/9/13 5:40 PM:liquibase: Reading views for APP @ jdbc:derby:/xxx/TestDb/yyyy.db ... INFO 1/9/13 5:40 PM:liquibase: Reading views for APP @ jdbc:derby:/xxx/TestDb/yyyy.db ... DEBUG 1/9/13 5:40 PM:liquibase: Reading foreign keys for APP @ jdbc:derby:/xxx/TestDb/yyyy.db ... INFO 1/9/13 5:40 PM:liquibase: Reading foreign keys for APP @ jdbc:derby:/xxx/TestDb/yyyy.db ... DEBUG 1/9/13 5:40 PM:liquibase: Reading primary keys for APP @ jdbc:derby:/xxx/TestDb/yyyy.db ... INFO 1/9/13 5:40 PM:liquibase: Reading primary keys for APP @ jdbc:derby:/xxx/TestDb/yyyy.db ... DEBUG 1/9/13 5:40 PM:liquibase: Reading columns for APP @ jdbc:derby:/xxx/TestDb/yyyy.db ... INFO 1/9/13 5:40 PM:liquibase: Reading columns for APP @ jdbc:derby:/xxx/TestDb/yyyy.db ... INFO 1/9/13 5:40 PM:liquibase: Shutting down derby connection: jdbc:derby:/xxx/TestDb/yyyy.db;shutdown=true Liquibase Update Failed: Syntax error: Encountered "CONSTRAINTS" at line 1, column 8. SEVERE 1/9/13 5:40 PM:liquibase: Syntax error: Encountered "CONSTRAINTS" at line 1, column 8. liquibase.exception.DatabaseException: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "CONSTRAINTS" at line 1, column 8. at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.createSnapshot(JdbcDatabaseSnapshotGenerator.java:251) at liquibase.snapshot.DatabaseSnapshotGeneratorFactory.createSnapshot(DatabaseSnapshotGeneratorFactory.java:69) at liquibase.diff.Diff.compare(Diff.java:63) at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:145) at liquibase.integration.commandline.Main.doMigration(Main.java:760) at liquibase.integration.commandline.Main.main(Main.java:134) Caused by: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "CONSTRAINTS" at line 1, column 8. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source) at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(Unknown Source) at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.isColumnAutoIncrement(JdbcDatabaseSnapshotGenerator.java:842) at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.readColumns(JdbcDatabaseSnapshotGenerator.java:369) at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.createSnapshot(JdbcDatabaseSnapshotGenerator.java:244) ... 5 more Caused by: java.sql.SQLException: Syntax error: Encountered "CONSTRAINTS" at line 1, column 8. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source) ... 16 more Caused by: ERROR 42X01: Syntax error: Encountered "CONSTRAINTS" at line 1, column 8. at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source) at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source) at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source) ... 10 more

1

1 Answers

1
votes

Your tool is generating SQL that Derby finds invalid, thus the message:

 Syntax error: Encountered "CONSTRAINTS" at line 1, column 8

If you can run your program with the JVM argument

  -Dderby.language.logStatementText=true

and then look in your derby.log file, you should be able to see the exact SQL statements that your tool is generating and issuing to Derby.

Here's a bit more docs on the derby.language.logStatementText propery: http://db.apache.org/derby/docs/10.9/ref/rrefproper43517.html