Autocommit



import java.sql.*;
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);}
}
}
}


Responses

0 Respones to "Autocommit"

Post a Comment

 

Recent Comments

Popular Posts

Return to top of page Copyright © 2010 | Platinum Theme Converted into Blogger Template by HackTutors