Results 1 to 4 of 4
  1. #1
    bigjo is offline Member
    Join Date
    Jul 2011
    Posts
    27
    Rep Power
    0

    Default connection to MS access database

    Hi, I am trying to get a connection to a microsoft acces database.

    I have written a DAO factory to get acces to different databases. I have installed a driver to get connection to an MySql database and everything goes fine.
    Now I am trying to get connection to an MS Access database, but I can't.

    Do I have to install a driver too? How can I access to my database (access 2007).

    I try with this code:

    Java Code:
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    c=DriverManager.getConnection("jdbc:odbc:DRIVER={Microsoft Access Driver(*.mdb)};DBQ=C:\\Trouw2.mdb","","");
    But I get following error:

    java.sql.SQLException: [Microsoft][ODBC-stuurprogrammabeheer] De naam van de gegevensbron is niet gevonden en er is geen standaardstuurprogramma opgegeven
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc .java:6956)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java :7113)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.j ava:3072)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOd bcConnection.java:323)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDrive r.java:174)
    at java.sql.DriverManager.getConnection(DriverManager .java:579)
    at java.sql.DriverManager.getConnection(DriverManager .java:221)
    at DAO.MSDAOFactory.getConnection(MSDAOFactory.java:3 4)
    at DAO.MSGameDAO.test(MSGameDAO.java:33)
    at HelloWorld.main(HelloWorld.java:30)
    Exception in thread "main" java.lang.NullPointerException
    at DAO.MSGameDAO.test(MSGameDAO.java:39)
    at HelloWorld.main(HelloWorld.java:30)
    Java Result: 1

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: connection to MS access database

    When you say "installed a driver", do you mean you included the JDBC connector jar in your class path? Every database requires it's own JDBC connector, you will need one for Access too.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: connection to MS access database

    Quick Google translation:
    "The name of the data source is not found and no default driver specified"

    Which means that it cannot find a data source matching the name given, which is an ODBC error.
    Does that mdb exist?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: connection to MS access database

    Oh, and what versions of OSes and Java are you on (including whether 32 or 64 bit).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 8
    Last Post: 03-20-2012, 05:45 PM
  2. Replies: 0
    Last Post: 02-16-2011, 01:30 PM
  3. Replies: 2
    Last Post: 02-11-2009, 04:43 AM
  4. connection between ms access and jcreator
    By tiger100plus in forum New To Java
    Replies: 0
    Last Post: 11-24-2008, 03:34 PM
  5. Replies: 1
    Last Post: 08-07-2007, 07:51 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
  •