Results 1 to 2 of 2
  1. #1
    Java Tip's Avatar
    Java Tip is offline Moderator
    Join Date
    Nov 2007
    Posts
    1,694
    Blog Entries
    430
    Rep Power
    9

    Default Accessing MS Access using DSN less connection

    Code snippet below shows how to access MS Access database with DSN less connection.

    Java Code:
    // For Access
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String myDB =
    "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/data/month.MDB";
    DBConn = DriverManager.getConnection(myDB,"","");
    
    // For Excel
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String myDB =
       "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=c:/data/month.xls;"
        + "DriverID=22;READONLY=false";
    DriverManager.getConnection(myDB,"","");

  2. #2
    sayan751 is offline Member
    Join Date
    Feb 2009
    Posts
    29
    Rep Power
    0

    Default

    i have tried your code in one of my program.it is running just fine when i am giving the full path.but other wise it fails.

    in my case my database resides in a sub folder inside the root project folder.is is it always necessary to give the full path??


    plz help.

Similar Threads

  1. accessing cddrive
    By milinkp in forum AWT / Swing
    Replies: 2
    Last Post: 02-06-2008, 08:38 AM
  2. Accessing Active Directory
    By javaplus in forum Advanced Java
    Replies: 1
    Last Post: 01-04-2008, 11:25 PM
  3. Replies: 1
    Last Post: 08-07-2007, 07:51 AM
  4. Replies: 1
    Last Post: 08-07-2007, 06:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •