• Post Reply Bookmark Topic Watch Topic
  • New Topic

handling sql exception, error code ...  RSS feed

Hussein Baghdadi
clojure forum advocate
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I have some questions about transactions.
1. as you know, getErrorCode( ) method returns a vendor's error code, so maybe differ from
database to other.
does getSQLState( ) method return a fixed value for a specific problem ?
I mean, I have MYSQL database and I shut it down, when catching the SQLException and calling
getSQLState( ) method, I got 08S01.
if I have oracle database and repeat these steps, will I recieve the same status ?
2. I have the following code :
try {
// create some statements and execute them
con.commit( );
} catch (SQLException e) {
// needs to handle
now, if SQLException is thrown , what should I do at catch statement ?
should I called con.rollback( ) method and then rethrow the exception ?
3. what does setHoldability( ) method mean ? when to use it ?
I have read the API but I don't understand it.
4. In which situation I should use save points ?
your help is really appreciated.
thanks a lot.
tommy k. lee
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using an EJB container to create your data access / persistence classes? (i.e. entity beans , session beans)

Or are you writing a stand-alone JDBC application?

For instance, if you are using an EJB container, the transactions are managed by the EJB container itself. The transactions are usually declared in the deployment descriptors at deploy time, rather than within your application code itself.

However, if you are writing a stand-alone JDBC application, you will need to manage the transactions manually, including roll-backs upon exceptions.

You can find more info @ http://www.javaworld.com/javaworld/jw-07-2000/jw-0714-transaction.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!