This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes Problem with Batch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with Batch" Watch "Problem with Batch" New topic
Author

Problem with Batch

Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
Hi,
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30392
    
150

Maki,

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?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 435
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 http://firebird.sourceforge.net
I have not used it as yet. Any ideas? Anyone?
Maki Jav
[ January 13, 2004: Message edited by: Maki Jav ]
 
Consider Paul's rocket mass heater.
 
subject: Problem with Batch