3 Replies Latest reply: Apr 9, 2013 12:04 PM by jschellSomeoneStoleMyAlias RSS

    How to create a database (file.mdb)?

    1000865

      Hello.
      I'm trying to create a .mdb database (Access) with Java but dont know how.
      How can i create a database if I need to be connected to an existing database?

      public class JavaApplication1 { /** * @param args the command line arguments */ public static void main(String[] args) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url = "jdbcdbcriver={Microsoft Access Driver " + "(*.mdb, *.accdb)};DBQ=C:\\Users\\David\\Desktop\\Vstup\\1\\db.mdb"; Connection con = DriverManager.getConnection(url); System.out.println("Connected!"); Statement stmt = null; ResultSet rs = null; // AND HERE I WANT TO CREATE A NEW DATABASE con2.close(); } catch (SQLException e) { System.out.println("SQL Exception: "+ e.toString()); } catch (ClassNotFoundException cE) { System.out.println("Class Not Found Exception: "+ cE.toString()); } } }