Possible Bug in Informix JDBC Driver with use of addBatch() with BigDecimal

Z

Zachi

Hello all,

I am observing strange behavior in use of batch inserts of BigDecimal
(money type in Informix): occasionally, instead of the null value the
previous non-null value of the field in the batch will be used. This
problem arises whether I set it the field implicitly or explicitly,
and does not appear if the insert is executed immediately. The driver
is 3.0JC3, and it happens on Sun Java on Windows XP and IBM java
bundled with Informix on Linux.Here is a code to describe the problem:

ResultSet r = ..."select field1, field2,...money_field,... from tab1
where...";
PreparedStatement p = ..."insert into tab2 (field1,
field2,...money_field,...) values (?,?,...?,...)";

//implicit NULL setting - inserts non-null values
while (r.hasNext()) {
...
p.setBigDecimal(i,r.getBigDecimal(i));
...
p.addBatch();
}
p.submitBatch();


//explicit NULL setting - inserts non-null values
while (r.hasNext()) {
...
BigDecimal b = r.getBigDecimal(i);
if (r.wasNull()) {
p.setNull(i, java.sql.Types.BigDecimal);
} else {
p.setBigDecimal(i,b);
}
...
p.addBatch();
}
p.submitBatch();



// non-use of batch - works with implicit and explicit
while (r.hasNext()) {
...
p.setBigDecimal(i,r.getBigDecimal(i));
...
p.execute();
}


Any ideas?

Thanks,

Zachi
 
L

Lee Fesperman

Zachi said:
ResultSet r = ..."select field1, field2,...money_field,... from tab1
where...";
PreparedStatement p = ..."insert into tab2 (field1,
field2,...money_field,...) values (?,?,...?,...)";

//implicit NULL setting - inserts non-null values
while (r.hasNext()) {
...
p.setBigDecimal(i,r.getBigDecimal(i));
...
p.addBatch();
}
p.submitBatch();

What is submitBatch()? It's not a standard JDBC method.
 
Z

Zachi

What is submitBatch()? It's not a standard JDBC method.

--
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)

submitBatch(), as well as its brothers addBatch(), executeBatch() and
clearBatch() are part
of the java.sql.Statement , which has been part of the standard since
1.4.2 (if not earlier). This is an interface to allow sending a batch
of commands to be executed, instead of sending them one at a time,
which allows for much higher performance due to eliminating a lot of
roundtrips.

Zachi
 
D

david

submitBatch(), as well as its brothers addBatch(), executeBatch() and
clearBatch() are part
of the java.sql.Statement , which has been part of the standard since
1.4.2 (if not earlier). This is an interface to allow sending a batch
of commands to be executed, instead of sending them one at a time,
which allows for much higher performance due to eliminating a lot of
roundtrips.

Zachi- Hide quoted text -

- Show quoted text -

Log a bug with IBM.
 
D

David Harper

Zachi said:
submitBatch(), as well as its brothers addBatch(), executeBatch() and
clearBatch() are part
of the java.sql.Statement , which has been part of the standard since
1.4.2 (if not earlier). This is an interface to allow sending a batch
of commands to be executed, instead of sending them one at a time,
which allows for much higher performance due to eliminating a lot of
roundtrips.

submitBatch isn't listed in the API docs for java.sql.Statement in Java
1.4.2 or 1.5.0 or 1.6.0

The only batch methods listed are addBatch, clearBatch and executeBatch.

Perhaps submitBatch is some kind of non-standard extension in the
Informix driver?

David Harper
Cambridge, England
 
Z

Zachi

submitBatch isn't listed in the API docs for java.sql.Statement in Java
1.4.2 or 1.5.0 or 1.6.0

The only batch methods listed are addBatch, clearBatch and executeBatch.

Perhaps submitBatch is some kind of non-standard extension in the
Informix driver?

David Harper
Cambridge, England

Sorry, my mistake. submitBatch() was a wrapper for executeBatch() in
my original code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top