• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java

 
Anil Kumarknr
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i do executeBatch() on a statement, which contains some erroneous records to be inserted, then in case of Oracle it is throwing SQLException instead of BatchUpdateException. If you execute the same using SQL server database, it throws BatchUpdateException. Why the behaviour is different in SQL server and in Oracle?
 
Bjarki Holm
Author
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anil,
<code>BatchUpdateException</code> extends <code>SQLException</code>. How did you find out that it was throwing <code>SQLException</code>? I mean, does it say so in the stack trace, or anywhere else?

------------------
Bjarki Holm
 
Anil Kumarknr
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i am doing stmt.executeBatch(), and cathing BatchUpdateException as well as SQLException. It is something like this.
try {
stmt.executeBatch();
} catch(BatchUpdateException buex) {
// some code
} catch(SQLException sqle) {
// some code
} catch(Exception e) {
// some code
}
If i am executing the above code using SQL server driver then control is coming to BatchUpdateException ( i am using Sprinta2000 SQL Server Driver here). If it is Oracle Driver (oracle.jdbc.driver.OracleDriver) then control is coming to SQLException. If i say sqle.getMessage() here,in the stack trace it is printing as "oracle.jdbc2.BatchUpdateException". I want to be consistent in both cases.
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be its dependent on the type of driver used.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic