Unclear DB2 database problem: Websphere connection pool

I am running a query from my java based web application running in a Websphere container. This request, however, is quite simple, fails with the strange 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 request is quite simple: it is simple as

select field1, field2 from <xyz table> where <xyz_pk> = ?

The primary key is INTEGER (4) and has data that has values ​​up to 99999999. But when I run this request, it starts in my web application over the connection received from the websphere connection pool, it starts to fail for pk> 35k + values. In jdbc binding code, I tried to make preparedStatement.setInt () and preparedStatement.setFloat (). But nothing works! It just works for something below 35k + and fails for anything above that.

Java int , 35k +, ? , , pkey!

- ? , ?

+3
5

... . int, small int int smallint, , .

+1

. float real - . , int, Int, long ; . , . ?

0

, , , - WAS JDBC, sql, .

, .

0

, ?

, websphere - , . java , java , .

We changed the data type in the database, and everything improved.

0
source

I remember this problem a while ago. I think I solved this by converting the value directly to an SQL statement. Something like that:

select DECIMAL (field1) AS field1, field2 from ...

0
source

Source: https://habr.com/ru/post/1712677/


All Articles