當連接到MySQL 5.6.5或更高版本的服務器時調用某些方法時可能會發生MySQLSyntaxErrorException。受影響的方法包括StatementImpl.execute()和PreparedStatement.execute()。原因是刪除了MySQL服務器中的SET OPTION語法。這些方法被修改爲在內部使用更新的SET語法。 (錯誤#13955027)Datanucleus 2.x和MySQL Bug#13955027(SET OPTION)
隨着DN 2.1版本,我得到這個異常:
javax.jdo.JDODataStoreException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=DEFAULT' at line 1
at org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:319)
at org.datanucleus.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1654)
at org.datanucleus.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1667)
NestedThrowablesStackTrace: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=DEFAULT' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1051)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3563)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3495)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2687)
at com.mysql.jdbc.StatementImpl.executeSimpleNonQuery(StatementImpl.java:1544)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1446)
at com.mysql.jdbc.ConnectionImpl.getTransactionIsolation(ConnectionImpl.java:3259)
at com.jolbox.bonecp.ConnectionHandle.getTransactionIsolation(ConnectionHandle.java:621)
at org.datanucleus.store.rdbms.ConnectionFactoryImpl$ManagedConnectionImpl.getConnection(ConnectionFactoryImpl.java:478)
at org.datanucleus.store.rdbms.ConnectionFactoryImpl$ManagedConnectionImpl.getXAResource(ConnectionFactoryImpl.java:417)
at org.datanucleus.store.connection.ConnectionManagerImpl.enlistResource(ConnectionManagerImpl.java:361)
at org.datanucleus.store.connection.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:228)
at org.datanucleus.store.connection.AbstractConnectionFactory.getConnection(AbstractConnectionFactory.java:56)
at org.datanucleus.store.rdbms.ConnectionFactoryImpl.getConnection(ConnectionFactoryImpl.java:352)
at org.datanucleus.store.AbstractStoreManager.getConnection(AbstractStoreManager.java:312)
at org.datanucleus.store.rdbms.request.FetchRequest.execute(FetchRequest.java:290)
at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.fetchObject(RDBMSPersistenceHandler.java:319)
at org.datanucleus.jdo.state.JDOStateManagerImpl.loadFieldsFromDatastore(JDOStateManagerImpl.java:1928)
at org.datanucleus.jdo.state.JDOStateManagerImpl.validate(JDOStateManagerImpl.java:4414)
at org.datanucleus.ObjectManagerImpl.findObject(ObjectManagerImpl.java:2785)
at org.datanucleus.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1649)
at org.datanucleus.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1667)
是否有辦法避免這種不升級DN庫?
爲什麼不在DN代碼中使用WHERE等基本信息有使用「SET OPTION」?畢竟你大概有一些錯誤,並且一些日誌條目,對應於代碼中的某一行,但沒有顯示它(某些堆棧跟蹤的頂部沒有顯示任何有用的內容......下面是什麼...嵌套...) – DataNucleus
我發佈了嵌套跟蹤。如果問題不在JDBC驅動程序中(使用解決該錯誤的最新版本),它只能在datanucleus或boneCP上。將進一步調查。謝謝。 – marcolopes
DN調用JDBC getConnection。然後調用JDBC驅動程序。這是唯一可以發出此類電話的東西。 QED – DataNucleus