没有为jdbc找到合适的驱动程序:odbc:Driver

时间:2017-03-28 06:31:12

标签: java-8 ms-office jdbc-odbc

我正面临从eclipse / java连接到MS Excel数据库的问题。我已经在下面提供了大部分细节。请帮我解决问题。欢迎您的建议。提前谢谢。

我在Windows 7 64位操作系统上安装了以下软件。

  • JDK 1.8 32bit(1.8.0_111)
  • MS Office standard 2010:32位
  • Eclipse Neon.2版本(4.6.2)32位。

我需要使用jdbc-odbc连接从我的eclipse连接到MS Excel数据库。由于Java 8不再支持jdbc-odbc桥,我按照以下步骤连接到Excel数据库:https://stackoverflow.com/a/36875001/2613428

但是我的eclipse仍然会抛出错误,我已经复制了堆栈跟踪:

java.sql.SQLException: No suitable driver found for jdbc:odbc:Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)}; DBQ=./Input/InputData.xlsx; DriverID=22; READONLY=false
    at java.sql.DriverManager.getConnection(DriverManager.java:689)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at framework.utility.Driver.dbConnection(Driver.java:53)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
        at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523)
        at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
        at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:326)
        at org.testng.SuiteRunner.run(SuiteRunner.java:289)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
        at org.testng.TestNG.runSuites(TestNG.java:1144)
        at org.testng.TestNG.run(TestNG.java:1115)
        at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
        at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)

如果我使用Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);它给出了:java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver

0 个答案:

没有答案