Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JDBC UpdateBatch

Status
Not open for further replies.

rdotson

IS-IT--Management
Feb 29, 2004
1
US

In the book "JDBC API tutorial and Reference, Second Edition" page 823 talks about BatchUpdate and catching the exceptions but
if you are using SQL 7.0 the SQL you can generate an error in sql and a exception will not be thrown example
a Table call test with the structure of
FirstName varchar(5)
LastName varchar(5)

try{
stmt.addBatch("Insert into test (FirstName,LastName) values ('Rob','Jones')");
stmt.addBatch("Insert into test (FirstName,LastName) values('Jim','Johnson')");
int[] updateCounts = stmt.executeBatch()}
catch(BatchUpdateException b){}


Using BatchUpdate the above statements will not throw a exception but the second record will not be add the the
SQL table but the first one will .

int[] updateCounts = stmt.executeBatch()
will return
updateCounts[0]=1
updateCounts[1]=1

but should return
updateCounts[0]=1
updateCounts[1]=0
and throw a exception

Which is not true.

Help!!!! what is the correct statements
Thanks
Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top