• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

handling sql exception, error code ...

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 {
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.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic