My commit rollback is not working, can anyone tell me why please?

Can anyone please help me figure out what is the problem with this code? it suppose to be correct but not for some unknown reason it didnt.
Here are the code --
* comiiit.java
* Created on March 23, 2006, 8:38 AM
package rib;
import java.io.*;
import java.net.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
* @author Rizal Ikhwan
* @version
public class comiiit extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Connection conn = null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("JDBC:ODBC:MyAccessSource");
conn.setAutoCommit(false);
Statement st = null;
PreparedStatement stmt = null ;
stmt = conn.prepareStatement("INSERT INTO Transaction values (?,?,?,?,?,?,?,?,?) ");
st = conn.createStatement();
String tType = "Ac2Db";
String ac ="0000";
String db ="0000";
String acBal = "1";
String cdBal = "0";
String amt = "1";
String nwacBal = "0";
String nwcdBal ="1";
String d = "date";
stmt.setString(1,d);
stmt.setString(2,ac);
stmt.setString(3,db);
stmt.setString(4,acBal);
stmt.setString(5,cdBal);
stmt.setString(6,amt);
stmt.setString(7,nwacBal);
stmt.setString(8,nwcdBal);
stmt.setString(9,tType);
stmt.executeUpdate();
conn.commit();
out.println("success");
}catch (Exception e){
try{
conn.rollback();
}catch(SQLException ignored){}
out.println("Fail");
}finally{
//clean up conn
try{
if(conn !=null) conn.close();
catch(SQLException ignored){ }
// conn.setAutoCommit(true);
/** Returns a short description of the servlet.
public String getServletInfo() {
return "Short description";
// </editor-fold>
//*************************

I think the problem is that you are using a database that does not support transactions.

Similar Messages

Maybe you are looking for