Connect the SQLException getNextException as the cause

This way when we get stack traces like the following, we actually
see the cause:

Exception in thread "main" com.google.gwtorm.client.OrmException: Insert failure: account_groups
        at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:171)
        at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:31)
        at com.google.gwtorm.client.impl.AbstractAccess.insert(AbstractAccess.java:55)
        at com.google.gerrit.server.GerritServer.initSystemConfig(GerritServer.java:193)
        at com.google.gerrit.server.GerritServer.loadSystemConfig(GerritServer.java:343)
        at com.google.gerrit.server.GerritServer.<init>(GerritServer.java:96)
        at com.google.gerrit.server.GerritServer.getInstance(GerritServer.java:78)
        at com.google.gerrit.pgm.CreateSchema.main(CreateSchema.java:28)
Caused by: java.sql.BatchUpdateException: Batch entry 0 INSERT INTO account_groups(name,owner_group_id,description,group_id)VALUES(Administrators,15,Gerrit Site Administrators,15) was aborted. Call getNextException to see the cause.
        at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2537)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1328)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:351)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2674)
        at com.google.gwtorm.jdbc.JdbcAccess.execute(JdbcAccess.java:227)
        at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:166)
        ... 7 more

Signed-off-by: Shawn O. Pearce <sop@google.com>
1 file changed