wood burning stoves 2.0*
The moose likes JDBC and the fly likes particular SQLCODE bypass in batch mode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "particular SQLCODE bypass in batch mode" Watch "particular SQLCODE bypass in batch mode" New topic
Author

particular SQLCODE bypass in batch mode

karshyam chandran
Greenhorn

Joined: Feb 17, 2005
Posts: 2
Hi,

I am running a java application in batch mode by reading records from a oracle table and if a matching row found in another table insert a record into 3rd table. While inserting record if I get sqlcode -803 ( duplicate row ) I would not want to stop the process because of sql exception. I want to skip this row and continue processing the next row .

Could anyone tell me how I can code this , please.

Thanks
karshyam
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30586
    
154

Karshyam,
Welcome to JavaRanch!

In JDBC, each transaction is commited to the database by default. So you can just catch the exception and move on to the next record.


[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
karshyam chandran
Greenhorn

Joined: Feb 17, 2005
Posts: 2
Thanks for your response.

I am trying to find out, is there a way to tell that if a sqlexception with a particular sql code happens donot catch the exception and continue processing as such it is OK to have that exception.

The only way to control this is by coding the logic in catch block I can do it. Before that I wanted to make sure , Is that the correct solution.

Any thoughts , please share it.

Thanks..
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30586
    
154

Karshyam,
Yes, you need to code logic in the catch block. The pattern for this is:
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: particular SQLCODE bypass in batch mode