Forums Register Login

handling sql exception, error code ...

+Pie Number of slices to send: Send
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 {
con.setAutoCommit(false);
// create some statements and execute them
con.commit( );
con.setAutoCommit(true);
} 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.
+Pie Number of slices to send: Send
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
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 772 times.
Similar Threads
when to use catch block and when to use throws
How to get exact exception type
Design Decision: Database User List
rollback, save point .....
how to properly catch/display exception in jsp ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:19:33.