473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Severe Problem using JDBC PreparedStatement with IBM DB2 Universal JDBC Driver as Type 4

Hi everyone

Description of the problem:
Using a PreparedStatement to write down an integer (int) plus a
timestamp for testing purposes. When read out again the integer looks
very different. We found that it was shifted three Bytes to the left,
i.e. 4 becomes hex 4000000 which is 67108864 in decimal base. This
means that the value written and the value read sometimes do not
match, which is of course inacceptable for all real world
applications.

The problem only arises when we use PreparedStatement in JDBC and when
used as Type 4 JDBC driver. It never happened as Type 2 driver.
The problem happened irregularly, with absolutely no recognizable
schema.

This is considered a severe flaw and prevents us from rolling this new
JDBC driver out.

Any help, especially from IBM, would be greatly appreciated.

Regards,
Dani

Code Snippet:

// SQL Stmts
final String DELETE_STMT = "DELETE FROM " + TEST_TABLE_NAME + "
WHERE NR = " + KEY;
final String INSERT_STMT = "INSERT INTO " + TEST_TABLE_NAME
+ " (NR, F_TIMESTAMP) VALUES(?, ?)";
final String SELECT_STMT = "SELECT F_TIMESTAMP FROM " +
TEST_TABLE_NAME
+ " WHERE NR = " + KEY;

Statement statement = null;
PreparedStatement ps = null;
try {
statement = conn.createStatement();

// delete and insert the data
statement.executeUpdate(DELETE_STMT);
ps = conn.prepareStatement(INSERT_STMT);
ps.setInt(1, KEY);
ps.setTimestamp(2, now);
ps.execute();

// re-read the data
ResultSet resultSet = statement.executeQuery(SELECT_STMT);
if (resultSet.next() != true) {
res.setFailure("Select returned no data.");
} else {
Configuration:

We are using DB2 Connect to connect to the DB on the z/OS.

[ibm][db2][jcc] Driver: IBM DB2 JDBC Universal Driver Architecture
1.2.117
[ibm][db2][jcc] Compatible JRE versions: { 1.3, 1.4 }
[ibm][db2][jcc] Target server licensing restrictions: { z/OS: enabled;
SQLDS: enabled; iSeries: enabled; DB2 for Unix/Windows: enabled;
Cloudscape: enabled }
[ibm][db2][jcc] Java Runtime Environment version 1.4.1_05
[ibm][db2][jcc] Java Runtime Environment vendor = Sun Microsystems
Inc.
[ibm][db2][jcc] Java Virtual Machine implementation version =
1.4.1_05-b01

[ibm][db2][jcc][Connection@e3b895] Successfully connected to server
jdbc:db2://gateway:50000/DB2U
[ibm][db2][jcc][Connection@e3b895] Database product name: DB2
[ibm][db2][jcc][Connection@e3b895] Database product version: DSN07011
[ibm][db2][jcc][Connection@e3b895] Driver name: IBM DB2 JDBC Universal
Driver Architecture
[ibm][db2][jcc][Connection@e3b895] Driver version: 1.2.117
[ibm][db2][jcc][Connection@e3b895] DB2 Correlator:
GA2444A0.GB40.00FABEC8075D

Trace:

[ibm][db2][jcc][Thread:main][Connection@e3b895] prepareStatement
(INSERT INTO SAIUUSR.SA_I_JDBCTEST (NR, F_TIMESTAMP) VALUES(?, ?))
called
[ibm][db2][jcc][Thread:main][Connection@e3b895] prepareStatement ()
returned PreparedStatement@1ce2dd4
[ibm][db2][jcc][Thread:main][PreparedStatement@1ce2dd4] setInt (1, 4)
called
[ibm][db2][jcc][Thread:main][PreparedStatement@1ce2dd4] setTimestamp
(2, 2004-02-16 15:43:25.218) called
[ibm][db2][jcc][Thread:main][PreparedStatement@1ce2dd4] execute ()
called
[ibm][db2][jcc][t4] Request.flush() called at 2004-2-16 15:43:25
Thread: main Tracepoint: 1
[ibm][db2][jcc][t4] SEND BUFFER: PRPSQLSTT (ASCII)
(EBCDIC)
[ibm][db2][jcc][t4] 0 1 2 3 4 5 6 7 8 9 A B C D E F
0123456789ABCDEF 0123456789ABCDEF
[ibm][db2][jcc][t4] 0000 0053D0510001004D 200D00442113C4C2
..S.Q...M ..D!... ..}....(......DB
[ibm][db2][jcc][t4] 0010 F2E4404040404040 4040404040404040
...@@@@@@@@@@@@@@ 2U
[ibm][db2][jcc][t4] 0020 D5E4D3D3C9C44040 4040404040404040
.......@@@@@@@@@@ NULLID
[ibm][db2][jcc][t4] 0030 4040E2E8E2D3C8F2 F0F0404040404040
@@........@@@@@@ SYSLH200
[ibm][db2][jcc][t4] 0040 404040405359534C 564C303100010005
@@@@SYSLVL01.... ...<.<......
[ibm][db2][jcc][t4] 0050 2116F1004ED04300 0100482414004049
!...N.C...H$..@I ..1.+}........ .
[ibm][db2][jcc][t4] 0060 4E5345525420494E 544F205341495555 NSERT
INTO SAIUU +......+.|......
[ibm][db2][jcc][t4] 0070 53522E53415F495F 4A44424354455354
SR.SA_I_JDBCTEST ................
[ibm][db2][jcc][t4] 0080 20284E522C20465F 54494D455354414D (NR,
F_TIMESTAM ..+.......(....(
[ibm][db2][jcc][t4] 0090 50292056414C5545 53283F2C203F2900 P)
VALUES(?, ?). &....<..........
[ibm][db2][jcc][t4] 00A0 000053D041000200 4D200800442113C4
...S.A...M ..D!.. ...}....(......D
[ibm][db2][jcc][t4] 00B0 C2F2E44040404040 4040404040404040
....@@@@@@@@@@@@@ B2U
[ibm][db2][jcc][t4] 00C0 40D5E4D3D3C9C440 4040404040404040
@......@@@@@@@@@ NULLID
[ibm][db2][jcc][t4] 00D0 404040E2E8E2D3C8 F2F0F04040404040
@@@........@@@@@ SYSLH200
[ibm][db2][jcc][t4] 00E0 4040404040535953 4C564C3031000100
@@@@@SYSLVL01... ...<.<.....
[ibm][db2][jcc][t4] 00F0 052146010053D051 0003004D200B0044
..!F..S.Q...M ..D ......}....(....
[ibm][db2][jcc][t4] 0100 2113C4C2F2E44040 4040404040404040
!.....@@@@@@@@@@ ..DB2U
[ibm][db2][jcc][t4] 0110 40404040D5E4D3D3 C9C4404040404040
@@@@......@@@@@@ NULLID
[ibm][db2][jcc][t4] 0120 404040404040E2E8 E2D3C8F2F0F04040
@@@@@@........@@ SYSLH200
[ibm][db2][jcc][t4] 0130 4040404040404040 5359534C564C3031
@@@@@@@@SYSLVL01 ...<.<..
[ibm][db2][jcc][t4] 0140 000100052105F100 42D0430003003C24
.....!...B.C...<$ ......1..}......
[ibm][db2][jcc][t4] 0150 12001300100976D0 03000425001A0671
.......v....%...q .......}........
[ibm][db2][jcc][t4] 0160 E4D000010025147A 0000000000040032
......%.z.......2 U}.....:........
[ibm][db2][jcc][t4] 0170 3030342D30322D31 362D31352E34332E
004-02-16-15.43. ................
[ibm][db2][jcc][t4] 0180 32352E3231383030 30000AD001000400
25.218000....... ...........}....
[ibm][db2][jcc][t4] 0190 04200E . .
...
[ibm][db2][jcc][t4]
[ibm][db2][jcc][t4] Reply.fill() called at 2004-2-16 15:43:25 Thread:
main Tracepoint: 2
[ibm][db2][jcc][t4] RECEIVE BUFFER: SQLCARD (ASCII)
(EBCDIC)
[ibm][db2][jcc][t4] 0 1 2 3 4 5 6 7 8 9 A B C D E F
0123456789ABCDEF 0123456789ABCDEF
[ibm][db2][jcc][t4] 0000 0056D04300010050 2408000000000030
..V.C...P$......0 ..}....&........
[ibm][db2][jcc][t4] 0010 3030303044534E20 2020202000444232 0000DSN
.DB2 ......+.........
[ibm][db2][jcc][t4] 0020 5520202020202020 2020202020202000 U
. ................
[ibm][db2][jcc][t4] 0030 0000000000000001 000000FFFFFFFF00
................. ................
[ibm][db2][jcc][t4] 0040 0000000000000020 2020202020202020 .......
................
[ibm][db2][jcc][t4] 0050 202000000000001C D053000200160035
........S.....5 ........}.......
[ibm][db2][jcc][t4] 0060 0006119C01F40006 119D00000006119E
................. .....4..........
[ibm][db2][jcc][t4] 0070 01F40047D0430002 00412411FF020000
....G.C...A$..... .4..}...........
[ibm][db2][jcc][t4] 0080 0000000400000000 000000F001000000
................. ...........0....
[ibm][db2][jcc][t4] 0090 0000000000000000 000000FF00000000
................. ................
[ibm][db2][jcc][t4] 00A0 1A00000000000000 890101F400000000
................. ........i..4....
[ibm][db2][jcc][t4] 00B0 0000000000000000 FF0026D052000300
...........&.R... ...........}....
[ibm][db2][jcc][t4] 00C0 2022180006114900 0000162110C4C2F2
"....I....!.... .............DB2
[ibm][db2][jcc][t4] 00D0 E440404040404040 4040404040404000
..@@@@@@@@@@@@@@. U .
[ibm][db2][jcc][t4] 00E0 56D0430003005024 0800000000003030
V.C...P$......00 .}....&.........
[ibm][db2][jcc][t4] 00F0 30303044534E2020 2020200044423255 000DSN
.DB2U .....+..........
[ibm][db2][jcc][t4] 0100 2020202020202020 2020202020200000
.. ................
[ibm][db2][jcc][t4] 0110 0000000000000100 0000FFFFFFFF0000
................. ................
[ibm][db2][jcc][t4] 0120 0000000000002020 2020202020202020 ......
................
[ibm][db2][jcc][t4] 0130 2000000000002BD0 5200040025220C00
......+.R...%".. .......}........
[ibm][db2][jcc][t4] 0140 0611490004000521 150100162110C4C2
...I....!....!... ..............DB
[ibm][db2][jcc][t4] 0150 F2E4404040404040 4040404040404040
...@@@@@@@@@@@@@@ 2U
[ibm][db2][jcc][t4] 0160 000BD00300040005 2408FF
.........$.. ..}........
[ibm][db2][jcc][t4]
[ibm][db2][jcc][ParameterMetaData@12f0999] BEGIN
TRACE_PARAMETER_META_DATA
[ibm][db2][jcc][ParameterMetaData@12f0999] Parameter meta data for
statement Statement@1ce2dd4
[ibm][db2][jcc][ParameterMetaData@12f0999] Number of parameter
columns: 2
isDescribed=true[ibm][db2][jcc][ParameterMetaData@12f0999] Column 1: {
label=, name=, type name=INTEGER, type=4, nullable=0, precision=10,
scale=0, schema name=, table name=, writable=true, sqlPrecision=0,
sqlScale=0, sqlLength=4, sqlType=496, sqlCcsid=0, sqlName=null,
sqlLabel=null, sqlUnnamed=<null>, sqlComment=<null>,
sqludtxType=<null>, sqludtRdb=<null>, sqludtSchema=<null>,
sqludtName=<null>, sqlxKeymem=<null>, sqlxGenerated=<null>,
sqlxParmmode=1, sqlxCorname=<null>, sqlxName=<null>,
sqlxBasename=<null>, sqlxUpdatable=<null>, sqlxSchema=<null>,
sqlxRdbnam=<null>, internal type=4, is locator parameter=false }
[ibm][db2][jcc][ParameterMetaData@12f0999] Column 2: { label=, name=,
type name=TIMESTAMP, type=93, nullable=1, precision=26, scale=6,
schema name=, table name=, writable=true, sqlPrecision=0, sqlScale=0,
sqlLength=26, sqlType=393, sqlCcsid=500, sqlName=null, sqlLabel=null,
sqlUnnamed=<null>, sqlComment=<null>, sqludtxType=<null>,
sqludtRdb=<null>, sqludtSchema=<null>, sqludtName=<null>,
sqlxKeymem=<null>, sqlxGenerated=<null>, sqlxParmmode=1,
sqlxCorname=<null>, sqlxName=<null>, sqlxBasename=<null>,
sqlxUpdatable=<null>, sqlxSchema=<null>, sqlxRdbnam=<null>, internal
type=93, is locator parameter=false }
[ibm][db2][jcc][ParameterMetaData@12f0999] { sqldHold=0, sqldReturn=0,
sqldScroll=0, sqldSensitive=0, sqldFcode=0, sqldKeytype=0,
sqldRdbnam=null, sqldSchema=null }
[ibm][db2][jcc][ParameterMetaData@12f0999] END
TRACE_PARAMETER_META_DATA
[ibm][db2][jcc][Thread:main][PreparedStatement@1ce2dd4] execute ()
returned false
Nov 12 '05 #1
4 6312
> The problem only arises when we use PreparedStatement in JDBC and when
used as Type 4 JDBC driver. It never happened as Type 2 driver.
The problem happened irregularly, with absolutely no recognizable
schema.


Someone pointed me to the question whether this flaw happens while
writing to the database or while reading from the database.

I have direct access to the database without going through JDBC and
thus can definitely say that the problem comes from writing to the
database.

Possibly this information can help the cracks to get the right
direction for the quest.

Thanks for any help.

Regards,
Dani
Nov 12 '05 #2
Hi,
you are using an older revision of the JDBC-Driver. The actual one is
of Version 1.5.54 DB2 V8.1.4.
It seems to me that this is quite similiar to one of the last APARS on
DB2, so please have a look at the IBM Patch-List for DB2.

Joerg
Nov 12 '05 #3
> you are using an older revision of the JDBC-Driver. The actual one is
of Version 1.5.54 DB2 V8.1.4.
It seems to me that this is quite similiar to one of the last APARS on
DB2, so please have a look at the IBM Patch-List for DB2.


Thanks for the hint.

I got the brand-new driver from FixPak 5 which is version 1.9.23 and
tried several VMs (JDK 1.4.1_03, JDK 1.4.1_05, JDK 1.4.2_03, all from
Sun, and BEA JRockit SP2 1.4.1_05) with several settings to make sure
that the behavior is not related to VM problems.

The result was the same.

One thing is remarkable, though. Somehow the problem seems to be able
to "survive" VM restarts. Very often in my tests - which consist of a
VM start, doing one test, writing to disk, and stopping the VM - the
problem suddenly showed up and then stayed until the end of the test
session. But of course, there were occasions when it changed back to
the healthy state again. But every time the problem state or the
healthy state stayed for several consecutive VM restarts.

Very strange.

The only explanation I have for this is that the problem must be
originated not on the client side, but on the gateway server (DB2
Connect) that we are using. I will investigate this further.

Any hints are still very much appreciated.

Regards,
Dani
Nov 12 '05 #4
DB2
Might be worth testing another JDBC driver that doesn't require a
gateway (ie StarSQL, from StarQuest).

Bob

da***********@email.ch (Dani) wrote in message news:<bf**************************@posting.google. com>...
you are using an older revision of the JDBC-Driver. The actual one is
of Version 1.5.54 DB2 V8.1.4.
It seems to me that this is quite similiar to one of the last APARS on
DB2, so please have a look at the IBM Patch-List for DB2.


Thanks for the hint.

I got the brand-new driver from FixPak 5 which is version 1.9.23 and
tried several VMs (JDK 1.4.1_03, JDK 1.4.1_05, JDK 1.4.2_03, all from
Sun, and BEA JRockit SP2 1.4.1_05) with several settings to make sure
that the behavior is not related to VM problems.

The result was the same.

One thing is remarkable, though. Somehow the problem seems to be able
to "survive" VM restarts. Very often in my tests - which consist of a
VM start, doing one test, writing to disk, and stopping the VM - the
problem suddenly showed up and then stayed until the end of the test
session. But of course, there were occasions when it changed back to
the healthy state again. But every time the problem state or the
healthy state stayed for several consecutive VM restarts.

Very strange.

The only explanation I have for this is that the problem must be
originated not on the client side, but on the gateway server (DB2
Connect) that we are using. I will investigate this further.

Any hints are still very much appreciated.

Regards,
Dani

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: mdh | last post by:
I am trying to learn the basics of MVC applications using a Tomcat infrastructure. I'm starting by building a simple application with: * a login.jsp page for a basic login form with a action...
2
by: Paul Reddin | last post by:
Hi, (V8.1 Fp2) Our application uses JDBC batch to execute mutiple insert statements and we saw a strange thing this morning. There were 4 SQL Insert statements in the batch, and we know the...
0
by: Priya | last post by:
Hi, I am having some problem with DB2 Universal JDBC driver. 1. The method getColumnType(columnNumber)of ResultSetMetaData always returns zero. 2. The method getColumnDisplaySize(ColumnNum)...
2
by: charl | last post by:
Hi, My apologies in advance if my terminology is slightly confused, I am new to all this. We have previously been running some SQL on DB2 (v7) utilising a type 3 driver, and have made the...
15
by: Joe Weinstein | last post by:
Hi. Below is a simple JDBC program to insert and extract a numerical value. When ResultSet.getDouble() is called, the same program produces different output on solaris than it does on Linux. I...
1
by: tom.eeraerts | last post by:
Hello, I have a problem migrating an application from v5r2 to v5r3. The problem is with the prepared statements. To see what the problem is, i extracted a small piece of code and debugged the...
3
by: Anoop | last post by:
Is it true that there are no type 4 jdbc drivers to connect to a DB2 server v7.1? The DB2 server is hosted on ACF2 (OS/390). We would be connecting from windows and solaris boxes. If it is true,...
0
by: rahulj | last post by:
Some of the queries, in our application, have trailing semicolon which works fine when the application uses DB2 CLI Native Driver. But when the driver is changed to DB2 Type 4 Universal Driver an...
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.