Results 1 to 16 of 16
Thread: Access connection error
- 04-21-2011, 04:14 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 64
- Rep Power
- 0
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
- 04-21-2011, 06:59 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
Google "DSNLess connection url" and hopefully you have the Access ODBC driver installed.
- 04-21-2011, 07:58 AM #3
Member
- Join Date
- Feb 2011
- Posts
- 64
- Rep Power
- 0
I believe that I am already using a "DSNless" connection. here is how i connect:
As i said in my original post, this was working on one computer. when i moved to a new computer, it stopped workingJava 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); }
thanks
- 04-21-2011, 08:05 AM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
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).
- 04-21-2011, 08:19 AM #5
Member
- Join Date
- Feb 2011
- Posts
- 64
- Rep Power
- 0
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?
- 04-21-2011, 08:21 AM #6
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
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.
- 04-21-2011, 08:25 AM #7
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
did you you check it or are you just assuming that, judging by your next statement I assume you are just assuming it
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.as i said, nothing has changed in my code except for the computers (the java source code is stored on a removable hard drive).
- 04-21-2011, 08:26 AM #8
Member
- Join Date
- Feb 2011
- Posts
- 64
- Rep Power
- 0
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.
- 04-21-2011, 08:28 AM #9
Member
- Join Date
- Feb 2011
- Posts
- 64
- Rep Power
- 0
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
- 04-21-2011, 08:28 AM #10
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
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.
- 04-21-2011, 08:37 AM #11
Member
- Join Date
- Feb 2011
- Posts
- 64
- Rep Power
- 0
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
- 04-21-2011, 08:42 AM #12
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
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).
- 04-21-2011, 08:46 AM #13
Member
- Join Date
- Feb 2011
- Posts
- 64
- Rep Power
- 0
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.
the question was how to fix it and add the drivers to the DSNI 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).
- 04-21-2011, 08:50 AM #14
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
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).
- 04-21-2011, 08:53 AM #15
Member
- Join Date
- Feb 2011
- Posts
- 64
- Rep Power
- 0
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
- 04-21-2011, 09:00 AM #16
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
Similar Threads
-
Access to app server db connection pool
By metazone in forum JDBCReplies: 3Last Post: 03-26-2011, 03:45 PM -
JDBC.ODBC Error : Microsoft Access Database not connection
By nizghat in forum New To JavaReplies: 0Last Post: 02-16-2011, 01:30 PM -
Connection to DLL using Java Native Access
By cowboy in forum New To JavaReplies: 1Last Post: 01-23-2010, 08:43 PM -
Accessing MS Access using DSN less connection
By Java Tip in forum Java TipReplies: 1Last Post: 03-31-2009, 05:25 PM -
connection between ms access and jcreator
By tiger100plus in forum New To JavaReplies: 0Last Post: 11-24-2008, 03:34 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks