connect 等连接省略
PreparedStatement ps,
ps.setObject(psIndex++, obj.getDoubleParameter1());
ps.setObject(psIndex++, obj.getDoubleParameter2());
ps.setObject(psIndex++, obj.getDoubleParameter3());
ps.execute();提示 om.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '4553' for key 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:1016)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:998)现在我急于需要把 PreparedStatement ps执行的SQL 打印出来 (我看了ps的函数集合 好像没有看到getsql函数)。
这个一定要的 , 因为Duplicate 字段值我在对应表里找了没有重复的值。
现在必须找到对应的sql , 用log方法写这个错误的sql到日志文件里。
问
如何找到PreparedStatement ps执行的SQL
PreparedStatement ps,
ps.setObject(psIndex++, obj.getDoubleParameter1());
ps.setObject(psIndex++, obj.getDoubleParameter2());
ps.setObject(psIndex++, obj.getDoubleParameter3());
ps.execute();提示 om.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '4553' for key 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:1016)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:998)现在我急于需要把 PreparedStatement ps执行的SQL 打印出来 (我看了ps的函数集合 好像没有看到getsql函数)。
这个一定要的 , 因为Duplicate 字段值我在对应表里找了没有重复的值。
现在必须找到对应的sql , 用log方法写这个错误的sql到日志文件里。
问
如何找到PreparedStatement ps执行的SQL
ps都没有初始化
ps.setObject(psIndex++, obj.getDoubleParameter1());
ps.setObject(psIndex++, obj.getDoubleParameter2());
ps.setObject(psIndex++, obj.getDoubleParameter3());
请注意 ps.execute(); (我必须知道是如何写入的sql)
(如果能找到sql 就不用到论坛里求助啦)
有人说要取到sql里面的statement就可以。 关键 ps.execute()都封装死了,不知道如何做