Results 1 to 5 of 5
Thread: jdbc-odbc cannot connect
- 12-01-2010, 01:14 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 8
- Rep Power
- 0
jdbc-odbc cannot connect
Hi,
I'm using a standard connection code for jdbc-odbc.
But I keep getting:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
-I've done everything on the microsoft page. (regedt32.exe : OCDB.INI set permissions to all, but no DSNName visible..also MAKER EIGENAAR doesnt have permission, - in english MAKER OWNER)
-uninstalled access, installed New Database Manager for office 64bit and reinstalled access.
- downloaded MDAC_TYP for 32-bit drivers.
-Changed permissions in control panal - data source . Also changed Target and Start
- changed location of my database to c:/users/Arne instead of C: since I always need to give authorization to write there.
if I execute: c:\windows\sysWOW64\odbcad32.exe I see all drivers
I get the message that driver is loaded, so I don't think problem is there, more likely in the authorization department :)...
This is really driving me crazy, spent many hours trying to fix it. And it might be an easy solution.
Just to be sure, here is my code:):
Java Code:package Database; import java.sql.*; public class Database { private Connection dbConnection; //constructor public Database(String dbFile) { loadDriver(); connectDatabase(dbFile); } //driver laden private void loadDriver() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("Laden van de driver is gelukt."); } catch (ClassNotFoundException e) { System.out.println("Kan de driver niet in de classpath vinden."); e.printStackTrace(); System.exit(1); } } //connectie tot stand brengen private void connectDatabase(String dbFile) { try { String protocol = "jdbc"; String subProtocol = "odbc"; String subName = "Driver={Microsoft Access Driver (*.mdb,*.accdb)}; " + "DBQ=" + dbFile; String URL = protocol + ":" + subProtocol + ":" + subName; dbConnection = DriverManager.getConnection(URL); } catch (SQLException error) { System.err.println("Error connecting to database: " + error.toString()); } } public Connection getDbConnection() { return dbConnection; } public void closeConnection() { try { dbConnection.close(); } catch (SQLException error) { System.err.println("Cannot disconnect database"); } } }Last edited by ArneBassez; 12-08-2010 at 03:54 AM.
- 12-07-2010, 12:49 PM #2
Member
- Join Date
- Dec 2010
- Posts
- 27
- Rep Power
- 0
Either database is not found, wrong name/URL or security issues.
- 12-08-2010, 02:17 AM #3
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
Please use code tags [CODE] [/CODE] .
Did you put password on your database? If yes, you have to give the username and password when trying to
connect in database.
Java Code:[b]EXAMPLE:[/b] dbConnection = DriverManager.getConnection(URL, "myUSERNAME", "myPASSWORD");
Last edited by mine0926; 12-08-2010 at 02:20 AM.
- 12-08-2010, 04:03 AM #4
Member
- Join Date
- Nov 2010
- Posts
- 8
- Rep Power
- 0
No, there is no password on my MS access database.
I have no problem making a connection on my old computer with the same database and program.
- 12-08-2010, 05:26 AM #5
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
Similar Threads
-
Can any one tel...who has developped JDBC-ODBC driver...?
By Hello1976 in forum New To JavaReplies: 1Last Post: 07-23-2010, 09:23 AM -
how to connect sql server 2005 with java without going to odbc
By kiki2009 in forum AWT / SwingReplies: 3Last Post: 03-28-2010, 06:55 AM -
Connect to Access without MS ODBC?
By ribbs2521 in forum New To JavaReplies: 5Last Post: 04-16-2009, 03:33 AM -
Help me this error in JDBC-ODBC connection
By lordelf in forum Java ServletReplies: 3Last Post: 04-04-2009, 08:37 AM -
Using JDBC-ODBC bridge
By Java Tip in forum Java TipReplies: 0Last Post: 02-06-2008, 09:21 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks