Results 1 to 5 of 5
- 05-12-2009, 11:05 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 42
- Rep Power
- 0
Same preparedstatement object 4 different queries..
Can I use like dis since it is not updating all the records..Its only taking the last one..
Actually i m getting same preparedstatement object for many queries in a loop..In this scenario its not working properly..
connection con.setAutoCommit(false);
PreparedStatement prepStmt = con.prepareStatement(
"UPDATE DEPT SET MGRNO=? WHERE DEPTNO=?");
prepStmt.setString(1,mgrnum1);
prepStmt.setString(2,deptnum1);
prepStmt.addBatch();
PreparedStatement prepStmt = con.prepareStatement(
"UPDATE EMP SET EMPNO=? WHERE DEPTNO=?");
prepStmt.setString(1,empno1);
prepStmt.setString(2,deptnum2);
prepStmt.addBatch();
Whether we can take same preparedstatement object for different query..??Its not giving any error but its not updating all the records but only the last one...
- 05-12-2009, 11:43 AM #2
Hi,
One small suggestion.
You are having different queries and statement objects are different.So, for first update u should call executeBatch and second update u should call again executeBatch.or else,like what u said, last statement object query only will get updated.Ramya:cool:
- 05-12-2009, 11:54 AM #3
Member
- Join Date
- Mar 2009
- Posts
- 42
- Rep Power
- 0
Thanks..
but can u tell me Is that same as individual preparedstatement execution..
- 05-12-2009, 11:58 AM #4
yes.
Just single statments only know.It will execute normally.
It is better u do normally removing the batch.Ramya:cool:
- 05-12-2009, 12:48 PM #5
Member
- Join Date
- Mar 2009
- Posts
- 42
- Rep Power
- 0
Similar Threads
-
Regarding PreparedStatement
By adeeb in forum JDBCReplies: 0Last Post: 06-09-2008, 09:07 PM -
Using PreparedStatement
By Java Tip in forum Java TipReplies: 0Last Post: 12-22-2007, 11:24 AM -
PreparedStatement
By Java Tip in forum Java TipReplies: 0Last Post: 12-05-2007, 03:56 PM -
calendar object in preparedStatement
By Heather in forum SWT / JFaceReplies: 3Last Post: 06-30-2007, 02:47 PM -
Help me. PreparedStatement
By Felissa in forum JDBCReplies: 2Last Post: 06-28-2007, 05:03 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks