accept value from user using buffered reader and insert into ms access database
import java.sql.*;
import java.io.*;
class BufferedInsert
{
public static void main(String s[])
{
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// it is used to accept value runtime
System.out.println("Enter The name");
String nm = reader.readLine();
System.out.println("Enter The ID");
int id = Integer.parseInt(reader.readLine());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//driver load
Connection con=DriverManager.getConnection("jdbc:odbc:demodb");
// connection
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);
}
}
}