Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / September 2003

Tip: Looking for answers? Try searching our database.

executebatch with nothing in it

Thread view: 
Mel Haynes Jr - 23 Sep 2003 17:33 GMT
I am having an issue with the Informix JDBC driver and wondering if anyone
else has it or has a solution to my problem. I have a method that fills a
preparedstatement with insert SQL ( prepare a Insert statement and then use
setXXX, addBatch() ). At the end of the loop, I perform the executeBatch().
The problem is, the loop may not have anything to insert into the
preparedStatement so there are times when the executeBatch() will have
nothing to execute. The problem I have is that, in this case, it throws a
SQLException indicating a null pointer.

SEVERE: ImportServices.CmptrImport.processItem
Trace stack
java.sql.BatchUpdateException: System or internal error
java.lang.NullPointerException
at
com.informix.jdbc.IfxPreparedStatement.executeBatch(IfxPreparedStatement.jav
a:3070)
at ImportServices.CmptrImport.processItem(CmptrImport.java:258)
at ImportServices.CmptrImport.processCompetitors(CmptrImport.java:159)
at ImportServices.CmptrImport.run(CmptrImport.java:104)
at java.lang.Thread.run(Thread.java:536)

This SQLException does not occur when using SQL Server ( JDBC driver from
DataDirect ). I read the thread about the internals of the preparedStatement
and know I can't see whats being sent to the DB, but can I find out if there
are ANY statements to process? I suppose I can have a counter to keep track
of this, but was wondering why it was throwing an exception. I did not read
anything in the JDBC doc that says it should.

Mel Haynes Jr
Mihai Pora - 23 Sep 2003 18:25 GMT
Hello,

 I guess you might have this issue with other JDBC drivers too (not sure).
 Anyway, my general solution to your problem would be :
boolean addedToBatch = false;
while (loop condition)
 if (need to add to batch)
 {
    add to batch
    addedToBatch = true;
 }
}
if (addedToBatch)
{
 execute batch
}

> I am having an issue with the Informix JDBC driver and wondering if anyone
> else has it or has a solution to my problem. I have a method that fills a
[quoted text clipped - 10 lines]
> java.lang.NullPointerException
>  at

com.informix.jdbc.IfxPreparedStatement.executeBatch(IfxPreparedStatement.jav
> a:3070)
>  at ImportServices.CmptrImport.processItem(CmptrImport.java:258)
[quoted text clipped - 10 lines]
>
> Mel Haynes Jr
Mel Haynes Jr - 24 Sep 2003 00:02 GMT
Thanks for the suggestion. That is what I did.

I found out the problem. I changed the Insert statement to include a new
field, but forgot to add another setLong() to the preparedstatement. So it
returned the nullpointer statement. I don't think that exception is handled
very well. In the DataDirect driver, it would tell me that the parameters do
not match( like it should ). I guess thats the price I pay for using free
drivers.

> Hello,
>
[quoted text clipped - 29 lines]
> > java.lang.NullPointerException
> >  at

com.informix.jdbc.IfxPreparedStatement.executeBatch(IfxPreparedStatement.jav
> > a:3070)
> >  at ImportServices.CmptrImport.processItem(CmptrImport.java:258)
[quoted text clipped - 14 lines]
> >
> > Mel Haynes Jr
Clemens Anhuth - 24 Sep 2003 09:24 GMT
> Thanks for the suggestion. That is what I did.
>
[quoted text clipped - 4 lines]
> not match( like it should ). I guess thats the price I pay for using free
> drivers.

Mel,

providing drivers/connectivity for their own DB engines is certainly a
field with mixed choices here and there, depending on vendor.

Notify the vendor about this problem, maybe. If opensource, maybe go
into the sourcecode and take a look around, it may be easy to fix and
then be more helpful to you in the development cycle.

With best regards

Clemens Anhuth

Signature

---------------------------------------------------
Clemens Anhuth       com.primebase @ clemens.anhuth

SNAP Innovation Softwareentwicklungs GmbH
22767 Hamburg
Altonaer Poststrasse 9a

Phone: ++49 (0)40 389 044 - 0             Fax: - 44

http://www.snap.de/       http://www.primebase.com/
---------------------------------------------------



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.