File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Problem with Batch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem with Batch" Watch "Problem with Batch" New topic

Problem with Batch

Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 439
I am using Statement and it's addBatch() and executeBatch(); Database is Ms Access. I am using addBatch() twice before executing it.
The sql queries are:
st.addBatch("Insert into table1 (ProjID,developer) values ('"+prjid+"','"+dev+"')");
st.addBatch("Insert into table2 (ProjID,dated) values ('"+prjid+"',#"+date+"#)");
where prjid and dev are string variables and date is sql date.
The tables has a relationship table1 -one-----many- table2 between ProjIDs.
Now the problem is that while the executing is giving no problem and the int [] array returned has 1,1 values ie it is effecting both tables records
but though the data is saved in the table1 and not in the table2....why?
point: using :
st.executeUpdate("("Insert into table1 (ProjID,developer) values ('"+prjid+"','"+dev+"')");
st.executeUpdate("("Insert into table1 (ProjID,dated) values ('"+prjid+"','"+date+"')");
I am getting results!
Please help?
Maki Jav

Help gets you when you need it!
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102


Is it safe to assume this is a typo? It should be table 2, not table 1.
If so, what error are you getting that tells you the data is not added?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 439
Thank you!
Everything is working fine! I was actually not closing connection earlier so I was getting data stored in table1 only and not in table2.
Now that I am closing the connecton after executeBatch(), I get the data saved in both of them.
I want to know what other free and professional level databases are available?
I have come across FireBird which is free and open source version of interbase6 (borland). It is homed at
I have not used it as yet. Any ideas? Anyone?
Maki Jav
[ January 13, 2004: Message edited by: Maki Jav ]
I agree. Here's the link:
subject: Problem with Batch
It's not a secret anymore!