Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Possible Bug in Informix JDBC Driver with use of addBatch() with BigDecimal

Reply
Thread Tools

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

 
 
Zachi
Guest
Posts: n/a
 
      04-25-2007
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

 
Reply With Quote
 
 
 
 
Lee Fesperman
Guest
Posts: n/a
 
      04-27-2007

Zachi wrote:
>
> 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.

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

 
Reply With Quote
 
 
 
 
Zachi
Guest
Posts: n/a
 
      04-27-2007
On Apr 27, 2:12 pm, Lee Fesperman <(E-Mail Removed)> wrote:
> Zachi wrote:
>
> > 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.
>
> --
> 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

 
Reply With Quote
 
david@smooth1.co.uk
Guest
Posts: n/a
 
      04-28-2007
On 27 Apr, 22:48, Zachi <(E-Mail Removed)> wrote:
> On Apr 27, 2:12 pm, Lee Fesperman <(E-Mail Removed)> wrote:
>
>
>
>
>
> > Zachi wrote:

>
> > > 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.

>
> > --
> > 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- Hide quoted text -
>
> - Show quoted text -


Log a bug with IBM.

 
Reply With Quote
 
David Harper
Guest
Posts: n/a
 
      04-28-2007
Zachi wrote:
> On Apr 27, 2:12 pm, Lee Fesperman <(E-Mail Removed)> wrote:
>> Zachi wrote:
>>
>>> 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.
>>
>> --
>> 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.


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
 
Reply With Quote
 
Zachi
Guest
Posts: n/a
 
      04-28-2007
On Apr 28, 5:37 am, David Harper <(E-Mail Removed)-net.com> wrote:
> Zachi wrote:
> > On Apr 27, 2:12 pm, Lee Fesperman <(E-Mail Removed)> wrote:
> >> Zachi wrote:

>
> >>> 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.

>
> >> --
> >> 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.

>
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BigDecimal(String) vs. BigDecimal(double) [Floating-point arithmetics] Stanimir Stamenkov Java 4 07-18-2008 10:49 AM
Possible Bug in Informix JDBC Driver Zachi Java 0 04-24-2007 11:11 PM
BigDecimal to power of BigDecimal czarnysfetr@gmail.com Java 3 02-05-2007 02:49 PM
How to parse the jdbc driver name from the jdbc .jar file Bruce Java 4 03-25-2006 12:01 PM
oracle.jdbc.OracleDriver vs oracle.jdbc.driver.OracleDriver Betty Java 1 05-21-2005 05:15 PM



Advertisments