Results 1 to 16 of 16
  1. #1
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default Access connection error

    hello everyone. I'm trying to connect to an access database. When I was working on this at the computer lab at my school, the connection worked just fine. when i got home, i get this error:

    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    I googled this and found it has something to do with my computers DSN but i'm not sure how to fix it. i tried various suggestions but nothing is working. when i go to ODBC Data Source Administrator (in control panel) I go to the System DSN tab and click Add but there are no Access *mdb, *accb choices available (only SQL Native Client, SQL Server, and SQL Server Native Client 10.0).

    I'm running Windows 7 Home Premium 64 bit OS.

    Thanks for your help
    jason

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Google "DSNLess connection url" and hopefully you have the Access ODBC driver installed.

  3. #3
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    I believe that I am already using a "DSNless" connection. here is how i connect:

    Java Code:
        public Connection connectToDatabase(String dbName) throws Exception {
            if (conn != null) {
                return conn;
            }
            String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
            if (System.getProperty("java.vendor").equals("Microsoft Corp.")) {
                //Microsoft VM users
                driver = "com.ms.jdbc.odbc.JdbcOdbcDriver";
            }
            String curDir = System.getProperty("user.dir"); 
            String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="
                    + curDir
                    + "\\"
                    + dbName;
    
            String username = "";
            String password = "";
            Class.forName(driver);
            return DriverManager.getConnection(url, username, password);
        }
    As i said in my original post, this was working on one computer. when i moved to a new computer, it stopped working

    thanks

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Well does the machine even have the Access ODBC driver?

    go to the cmd shell and execute "regedit" and go to
    HKEY_LOCAL_MACHINE->SOFTWARE->ODBC->ODBCINST.INI and see if an mdb driver is anywhere in that list.

    And then also print out the path you're using and see if it is even correct. And there is no reason to use "\\" simply use "/", much less error-prone (yes, even on Windows systems, of course).

  5. #5
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    thank you for your reply. yes, my path is correct. as i said, nothing has changed in my code except for the computers (the java source code is stored on a removable hard drive). No, i dont believe that this computer has Access ODBC drivers installed. As i mentioned in my original post, when i try to add them to the DSN, the access option is missing. is there another way to install the drivers?

  6. #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Install MS Office.

    Edit: Really, if you don't have the odbc driver installed, the jdbc-odbc bridge cannot use it, of course. And the access odbc driver is MS proprietary software.

  7. #7
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by jasonwucinski View Post
    thank you for your reply. yes, my path is correct.
    did you you check it or are you just assuming that, judging by your next statement I assume you are just assuming it
    as i said, nothing has changed in my code except for the computers (the java source code is stored on a removable hard drive).
    And? does it hurt to actually check the path. Since you are using the current directory (i.e. cwd/pwd) than the code is almost irrelevant in relation to how you execute it.

  8. #8
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    ms office is installed. if you read the original post, I'm asking how to do exactly that. I know I need the odbc drivers installed the problem is, i cant install them.

  9. #9
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    no, i checked it out. i printed out the path and it is correct:
    here is what the url connection looks like
    jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=H:\MyDatabaseProgram\MyClients.accdb

  10. #10
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Did you check the registry path I told you to check. And if MS office is installed (including access) then the odbc driver for access is installed the problem (edit: then) goes back to your understanding of cwd and the location of the mdb file.
    Last edited by masijade; 04-21-2011 at 08:38 AM.

  11. #11
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    ok. yes, I did check the registry and it is not there (only SQL Native Client, SQL Server, and SQL Server Native Client 10.0 are there). Microsoft and Access are both installed. The path to my database, which is located in the root directory of my program, is correct. if i type it into my explorer, it goes to the file. I'm not sure what you mean by "cwd" though

  12. #12
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    cwd is "current working directory", i.e. the thing that the "user.dir" system property points to.

    And if access and office are installed and the odbc driver not, then ask microsoft (they do have a support forum), and/or try running the program as administrator once (by right clicking and selecting "run as administrator", as even if you have an adminstrator account you do not have full adminstrator rights unless you have disactivated UAC which I highly reccommend you do not do).

  13. #13
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    yeah, i've tried running it as admin. i know what the problems is (the missing drivers from the DSN) due to windows 7 and the 64bit OS.

    I googled this and found it has something to do with my computers DSN but i'm not sure how to fix it. i tried various suggestions but nothing is working. when i go to ODBC Data Source Administrator (in control panel) I go to the System DSN tab and click Add but there are no Access *mdb, *accb choices available (only SQL Native Client, SQL Server, and SQL Server Native Client 10.0).
    the question was how to fix it and add the drivers to the DSN

  14. #14
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    And I just said, ask microsoft. And all you said in your post was "found it has something to do with my computers DSN" without even saying that Office and Access were installed, so, IOW, we were starting from ground zero.

    Edit: P.S. you do not "add drivers to the DSN", you add drivers to the system and a "DSN" is simply a "configuration" designating an installed driver and a path (usually either a filepath or network path).

  15. #15
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    lol. i appreciate your help. it's just kind of funny. who would try to develop a database application with access without first installing microsoft office or access lol

  16. #16
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Well, seeing as how you "moved from one computer to another" it was perfectly possible since many "newbies" assume that the JDBC-ODBC bridge is the ODBC Driver.

Similar Threads

  1. Access to app server db connection pool
    By metazone in forum JDBC
    Replies: 3
    Last Post: 03-26-2011, 03:45 PM
  2. Replies: 0
    Last Post: 02-16-2011, 01:30 PM
  3. Connection to DLL using Java Native Access
    By cowboy in forum New To Java
    Replies: 1
    Last Post: 01-23-2010, 08:43 PM
  4. Accessing MS Access using DSN less connection
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 03-31-2009, 05:25 PM
  5. connection between ms access and jcreator
    By tiger100plus in forum New To Java
    Replies: 0
    Last Post: 11-24-2008, 03:34 PM

Posting Permissions

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