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