java connecting to access database problem
When trying to connect the access db i get this error: [Microsoft][ODBC开发者_JAVA技巧 Driver Manager] Data source name not found and no default driver specified this is my code:
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
DriverManager.getConnection ("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=d:\task.accdb", "" , "");
I' guessing it have to do someting with the fact that it is 64bit? How can this be fixed? and if not are they any other databases like access that I can use?
Thank's In Advance.
In your connection string there is unescaped \
. Try with this string:
DriverManager.getConnection ("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=d:\\task.accdb", "" , "");
You can also create System DSN for your database (in case of 64 bit systems you can do in in both 32 bit and 64 bit environments) and then use connect string like:
jdbc:odbc:northwind
精彩评论