class AutoCommitDemo
{
public static void main(String s2[])
{
Connection con=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:syam");
con.setAutoCommit(false);
Statement st=con.createStatement();
st.executeUpdate("insert into student values(1,'veena')");
st.executeUpdate("insert into mark values(1,50)");
con.commit();
}catch(Exception e1){
try{
con.rollback();
}catch(Exception e2){System.out.println(e2);}
}
finally{
try{
con.setAutoCommit(true);
}catch(Exception e2){System.out.println(e2);}
}
}
} Labels: Java
Responses
0 Respones to "Autocommit"
Post a Comment