Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package college;
- import java.sql.*;
- public class Update {
- public static void main(String[] args) {
- Connection con;
- PreparedStatement pstmt;
- try
- {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("Jdbc:Odbc:Aakarshap");
- con.setAutoCommit(false); //Set this silly property to false
- String qrystr="Update Employee set Salary=Salary+1000 where eNum=?";
- pstmt=con.prepareStatement(qrystr);
- pstmt.setInt(1, 1001);
- pstmt.executeUpdate();
- con.commit(); //Manually commit like a God
- }
- catch(ClassNotFoundException ce)
- {
- System.out.println("Error"+ce);
- }
- catch(SQLException se)
- {
- System.out.println("Error"+se);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement