I've attached a test case for what I believe is a bug in jtopen, or at least odd behavior. Setting a prepared statement parameter to a 5 digit BigDecimal works fine. Setting it to a 6 digit BigDecimal causes the following output with the test program:
Connected
values set ok
java.sql.DataTruncation: Data truncation
Exception: java.sql.DataTruncation: Data truncation
sql state: 22001
at com.ibm.as400.access.AS400JDBCPreparedStatement.testDataTruncation(AS400JDBCPreparedStatement.java:3453)
at com.ibm.as400.access.AS400JDBCPreparedStatement.setValue(AS400JDBCPreparedStatement.java:3364)
at com.ibm.as400.access.AS400JDBCPreparedStatement.setBigDecimal(AS400JDBCPreparedStatement.java:2094)
at JTopenTest.main(JTopenTest.java:37)
We're trying to upgrade from an ANCIENT version of jtopen to the latest 7.6 and are being blocked by this bug. Iseries is v6R1. To use test case, set user, password, and iseries url constants and then run.
test case for data truncation
upped priority. Shouldn't be a medium.
What's the datatype and size of the parameter? If try to set a value that only holds 5 digits, setting it to a 6 digit value will throw this exception.
The older versions of the driver did not properly detect application errors like this.
Please set the status back to open if you think the 6 digit big decimal should fit into the specified data type.
The testcase declares that parameter a DECIMAL. The default precision / scale for decimal is (5,0). A 6 digit number doesn't fit into a 5 digit value.
By the way -- truncation means a loss of digits of low significance. So, 1111.1 to 1111 would be truncation. A conversion from 654321 to 54321 would just be an error.
thanks for the clarification and quick response.
John,
I noticed this strange behavior in my log today on a call that works 99.9% of the time. I received the following on a query that sets a string as a parameter. This happens sporadic and cant really be reproduced easily. Do you have any suggestions?
Caused by: java.sql.DataTruncation: Data truncation
at com.ibm.as400.access.AS400JDBCPreparedStatement.testDataTruncation(AS400JDBCPreparedStatement.java:3494) ~[jt400.jar:JTOpen 7.8]
at com.ibm.as400.access.AS400JDBCPreparedStatement.setValue(AS400JDBCPreparedStatement.java:3402) ~[jt400.jar:JTOpen 7.8]
at com.ibm.as400.access.AS400JDBCPreparedStatement.setString(AS400JDBCPreparedStatement.java:3048) ~[jt400.jar:JTOpen 7.8]
at sun.reflect.GeneratedMethodAccessor3195.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_05]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_05]
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) ~[hibernate-core-4.1.7.Final.jar:4.1.7.Final]
... 133 common frames omitted