Help with mysql connector java 6.x+
Posted by: Pala Dox
Date: October 14, 2017 06:39AM

Hi, i tryed updating the mysql connector in the gerrit project from 5.1 to 6.x. But it is failing because it is not applying the schema correctly now.

I think it is caused by https://github.com/mysql/mysql-connector-j/commit/3d3d0c157491d98b077429e0a5e23331dc69b0b0#diff-6a68eedf6a3f272bae764dc0ecc4eba8 but no evidence yet, ie haven't been able to revert it to try. But the traceback here

Exception in thread "main" com.google.gwtorm.server.OrmException: insert failure on schema_version
at com.google.gwtorm.schema.sql.SqlDialect.convertError(SqlDialect.java:159)
at com.google.gwtorm.schema.sql.DialectMySQL.convertError(DialectMySQL.java:230)
at com.google.gwtorm.jdbc.JdbcAccess.convertError(JdbcAccess.java:484)
at com.google.gwtorm.jdbc.JdbcAccess.insert(JdbcAccess.java:169)
at com.google.gerrit.server.schema.SchemaCreator.create(SchemaCreator.java:89)
at com.google.gerrit.server.schema.SchemaUpdater.update(SchemaUpdater.java:111)
at com.google.gerrit.pgm.init.BaseInit$SiteRun.upgradeSchema(BaseInit.java:388)
at com.google.gerrit.pgm.init.BaseInit.run(BaseInit.java:145)
at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:203)
at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:108)
at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:63)
at Main.main(Main.java:24)
Caused by: java.sql.BatchUpdateException: Table 'reviewdb4.schema_version' doesn't exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.cj.core.util.Util.handleNewInstance(Util.java:185)
at com.mysql.cj.core.util.Util.getInstance(Util.java:168)
at com.mysql.cj.core.util.Util.getInstance(Util.java:175)
at com.mysql.cj.jdbc.exceptions.SQLError.createBatchUpdateException(SQLError.java:212)
at com.mysql.cj.jdbc.PreparedStatement.executeBatchedInserts(PreparedStatement.java:1545)
at com.mysql.cj.jdbc.PreparedStatement.executeBatchInternal(PreparedStatement.java:1210)
at com.mysql.cj.jdbc.StatementImpl.executeBatch(StatementImpl.java:1020)
at com.google.gwtorm.schema.sql.SqlDialect.executeBatch(SqlDialect.java:435)
at com.google.gwtorm.jdbc.JdbcAccess.execute(JdbcAccess.java:455)
at com.google.gwtorm.jdbc.JdbcAccess.insertAsBatch(JdbcAccess.java:213)
at com.google.gwtorm.jdbc.JdbcAccess.insert(JdbcAccess.java:164)
... 13 more
Caused by: java.sql.SQLSyntaxErrorException: Table 'reviewdb4.schema_version' doesn't exist
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:112)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:116)
at com.mysql.cj.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1867)
at com.mysql.cj.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2029)
at com.mysql.cj.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:1970)
at com.mysql.cj.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:4996)
at com.mysql.cj.jdbc.PreparedStatement.executeBatchedInserts(PreparedStatement.java:1506)
... 19 more

leads to executeBatch

But we use gwtorm, and it's an int but in the mysql connector it was changed to a long and made a private function.

https://github.com/GerritCodeReview/gwtorm/blob/master/src/main/java/com/google/gwtorm/schema/sql/SqlDialect.java#L434

In the mariadb connector, it is a int https://github.com/MariaDB/mariadb-connector-j/blob/e01335be8056d27f830038b6a276197d8113e102/src/main/java/org/mariadb/jdbc/MariaDbPreparedStatementServer.java#L218

See https://bugs.chromium.org/p/gerrit/issues/detail?id=7331 our issue.

wondering could we have help please to allow us to upgrade?

Options: ReplyQuote


Subject
Written By
Posted
Help with mysql connector java 6.x+
October 14, 2017 06:39AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.