wood burning stoves*
The moose likes JDBC and the fly likes Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Java" Watch "Java" New topic
Author

Java

Anil Kumarknr
Greenhorn

Joined: Jun 21, 2001
Posts: 3
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

Joined: May 25, 2001
Posts: 65
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


Bjarki Holm
Anil Kumarknr
Greenhorn

Joined: Jun 21, 2001
Posts: 3
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

Joined: Feb 06, 2001
Posts: 358
May be its dependent on the type of driver used.


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
 
jQuery in Action, 2nd edition
 
subject: Java