Skip to main content

Posts

Showing posts with the label java program insert record from table using PreparedStatement

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...

Labels

Show more