I am running a query from my java based web app running in a Websphere container. This query however, being pretty simple, fails with a weird erorr as follows:
[5/15/09 16:50:33:828 IST] 0000001e SystemErr R com.ibm.db2.jcc.b.zd: Invalid data conversion:Requested conversion would result in a loss of precision of 40000
[5/15/09 16:50:33:828 IST] 0000001e SystemErr R at com.ibm.db2.jcc.b.q.a(q.java:137)
[5/15/09 16:50:33:828 IST] 0000001e SystemErr R at com.ibm.db2.jcc.b.q.a(q.java:1189)
[5/15/09 16:50:33:828 IST] 0000001e SystemErr R at com.ibm.db2.jcc.b.ad.a(ad.java:1217)
[5/15/09 16:50:33:828 IST] 0000001e SystemErr R at com.ibm.db2.jcc.b.ad.kb(ad.java:2977)
[5/15/09 16:50:33:828 IST] 0000001e SystemErr R at com.ibm.db2.jcc.b.ad.d(ad.java:1970)
[5/15/09 16:50:33:828 IST] 0000001e SystemErr R at com.ibm.db2.jcc.b.ad.d(ad.java:2342)
[5/15/09 16:50:33:828 IST] 0000001e SystemErr R at com.ibm.db2.jcc.b.ad.U(ad.java:489)
[5/15/09 16:50:33:828 IST] 0000001e SystemErr R at com.ibm.db2.jcc.b.ad.executeQuery(ad.java:472)
[5/15/09 16:50:33:828 IST] 0000001e SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:559)
The query is pretty simple : it is as simple as
select field1, field2 from <xyz table> where <xyz_pk> = ?
The primary key is a INTEGER(4) and has data that has values up to 99999999. But however, when I run this query is run in my web app on a connection obtained from websphere connection pool, it starts failing for pk values > 35k+. In the jdbc binding code, I tried doing a preparedStatement.setInt() and preparedStatement.setFloat(). But nothing seems to work!! It just works for anything below 35k+ and fails for everything above that.
Java's int size is much bigger than 35k+, so why would this query fail with this error? This happens just from my application, when I try the same query with a database client of my choice, proper results are being obtained for all values of the pkey!
Did anyone faced this issue before? If yes, how did you get around it?
My bad.. the issue was in binding. My query had an integer and small int field and I was binding small to int and int to smallint, hence the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With