从java建立连接到2010年64位 [英] Establishing connection from java to access 2010 64bit
问题描述
经过几个教程和博客文章,我没有成功尝试设置从java到微软访问数据库的连接。我的系统规格是
After going through several tutorials and blog posts, i have unsuccessfully tried to set up a connection from java to a microsoft access database. my system specifications are
win 7 [64 bit] odbcad32.ese [64 bit] access 2010 [64 bit] jre6 [64
bit]
win 7 [64 bit] odbcad32.ese [64 bit] access 2010 [64 bit] jre6 [64 bit]
我用于建立连接的代码:
public Connection makeConn() throws ClassNotFoundException, SQLException
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Users\\ARIFAH\\Desktop\\sampleDb.mdb");
return conn;
}
< - [位于路径%windir%\system32 \odbcad32.exe ]
我执行了以下任务
-
USER DSN TAB ADD-> Microsoft Access Driver(* .mdb,* .accdb)[file ACEODBC.dll] - >完成
USER DSN TAB ADD->Microsoft Access Driver (*.mdb, *.accdb ) [file ACEODBC.dll] ->Finish
数据源名称:TestDriver; 说明:测试驱动程序访问2010 64位;
Data Source Name: TestDriver ; Description: test driver for access 2010 64 bit ;
DataBase - >选择 - >浏览:C:\Users\ARIFAH\Desktop\sampleDb.mdb - > ok
DataBase->select ->browse: C:\Users\ARIFAH\Desktop\sampleDb.mdb -> ok
apply
ok
现在,当我尝试运行我的应用程序,这是错误,得到,
now when i try to run my application, this is the error that i m getting,
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at dataBase.connection.makeConn(connection.java:22)
at newmodulewizrd.ui.App.<init>(App.java:32)
at archetypedcomponent.commands.newModuleHandler.execute(newModuleHandler.java:39)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:770)
at org.eclipse.ui.menus.CommandContributionItem.access$10(CommandContributionItem.java:756)
at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:746)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
帮助它?
推荐答案
根据这个博客,你必须运行32位版本的Java,或使用64位版本的办公室驱动程序:
According to this blog, you either have to run 32-bit version of Java, or use 64-bit version of office drivers:
http://www.selikoff.net/2011/07/26/connecting-to-ms-access-file -via-jdbc-in-64-bit-java /
这篇关于从java建立连接到2010年64位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!