Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

particular SQLCODE bypass in batch mode

 
karshyam chandran
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
karshyam chandran
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karshyam,
Yes, you need to code logic in the catch block. The pattern for this is:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic