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.
tommy k. lee
Greenhorn
Joined: Jun 16, 2004
Posts: 20
posted
0
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.