我正在尝试使用JAVA JDBC在DB2表上运行一个小的更新查询。当我使用准备好的语句绑定变量传递值时,会出现此错误。我尝试更新的列声明为DECIMAL(13,2)。请有人指导我如何解决此问题。
DB2版本11.1
Java版本8
从IBM网站下载的最新JDBC驱动程序
Windows
String query="update ALLOC_SUM set stat_amt=? where cost_cntr=50";
PreparedStatement stmt = connection.prepareStatement(query);
BigDecimal bd=new BigDecimal("2.54");
stmt.setBigDecimal(1, bd);
stmt.executeUpdate();
异常堆栈跟踪
com.ibm.db2.jcc.am.SqlException: [jcc][t4][1037][11192][3.71.22] Exception occurred during Decimal floating point conversion. See attached Throwable for details. ERRORCODE=-4220, SQLSTATE=null
at com.ibm.db2.jcc.am.gd.a(gd.java:797)
at com.ibm.db2.jcc.am.gd.a(gd.java:66)
at com.ibm.db2.jcc.am.gd.a(gd.java:98)
at com.ibm.db2.jcc.t4.eb.b(eb.java:1903)
at com.ibm.db2.jcc.t4.hb.a(hb.java:1578)
at com.ibm.db2.jcc.t4.hb.a(hb.java:1362)
at com.ibm.db2.jcc.t4.hb.a(hb.java:1350)
at com.ibm.db2.jcc.t4.hb.a(hb.java:1276)
at com.ibm.db2.jcc.t4.hb.a(hb.java:876)
at com.ibm.db2.jcc.t4.hb.a(hb.java:221)
at com.ibm.db2.jcc.t4.wb.a(wb.java:177)
at com.ibm.db2.jcc.am.hp.a(hp.java:3417)
at com.ibm.db2.jcc.am.hp.a(hp.java:4253)
at com.ibm.db2.jcc.am.hp.b(hp.java:4062)
at com.ibm.db2.jcc.am.hp.jc(hp.java:792)
at com.ibm.db2.jcc.am.hp.executeUpdate(hp.java:770)
at net.abcbs.cost.batch.job.TestJobImpl.run(TestJobImpl.java:45)
at net.abcbs.cost.batch.deploy.BatchJobAdapter.execute(BatchJobAdapter.java:18)
at net.abcbs.cost.batch.deploy.UnitTestJobRunner.main(UnitTestJobRunner.java:11)
Caused by: com.ibm.db2.jcc.a.ConversionException: [jcc][converters][606][10995]Decfloat conversion requires JDK1.5 null
at com.ibm.db2.jcc.a.e.a(e.java:356)
at com.ibm.db2.jcc.a.e.b(e.java:217)
at com.ibm.db2.jcc.t4.eb.b(eb.java:1899)
... 15 more
Caused by: java.lang.NullPointerException
at com.ibm.db2.jcc.a.e.a(e.java:334)
... 17 more