0

I am writing a very simple code to connect MS Access database to my java program using netBeans. The driver ucanaccess and MS access file is placed in the very same folder. Kindly guide me through it.

 public static void main(String[] args) {
    // TODO code application logic here
    Connection c = null;
    Statement s = null;
    ResultSet rs = null;
    try{
         Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
    c = DriverManager.getConnection("jdbc:ucanaccess://First1.accdb");
    s = c.createStatement();
    s.executeUpdate("insert into std values(5, 'junaid')");
    //set classpath=.c:./*;
    }catch(Exception e)
    {
        System.out.println(e);
    }

}
Gord Thompson
  • 98,607
  • 26
  • 164
  • 342
Saim Mehmood
  • 861
  • 7
  • 14

0 Answers0