Skip to main content

Posts

Showing posts with the label java MS ACCESS insert

java program insert record using PreparedStatement

java program insert  record  using  PreparedStatement java MS ACCESS  insert,update  delete using  PreparedStatement import java.sql.*; class InsertPs { public static void main(String s[]) { try{ int id=Integer.parseInt(s[0]); String nm=s[1]; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:demodb"); PreparedStatement psmt=con.prepareStatement("insert into demo(id,dname)values(?,?)"); psmt.setInt(1,id); psmt.setString(2,nm); int result=psmt.executeUpdate(); System.out.println("record Inserted"+result); con.close(); } catch(Exception e) {System.out.println(""+e);} } } Learn Delete record from MS ACCESS USING PREPAIRED STATEMENT CLICK HERE insert query in java using prepared statement how to insert values into table in mysql using java how to use prep...

java MS ACCESS insert,update delete using PreparedStatement

java program delete record from table using  PreparedStatement java MS ACCESS  insert,update  delete using  PreparedStatement import java.sql.*; class DeletePreparest {   public static void main(String s[])   {     try {   int cno=Integer.parseInt(s[0]);  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  Connection con=DriverManager.getConnection("jdbc:odbc:demodb"); // Statement smt=con.createStatement();  PreparedStatement psmt=con.prepareStatement("delete from demo where id=?");  psmt.setInt(1,cno);  int result=psmt.executeUpdate();       System.out.println("record deleted"+result);  con.close(); } catch(Exception e){    System.out.println("exce"+e);}         } }

Labels

Show more