Connect to an Access database in Java using NetBeans

自闭症网瘾萝莉.ら 提交于 2019-12-06 19:47:27
Gord Thompson

in the ODBC Administrator app, i don't have Ms access Driver, i just have SQL Driver.

Now that the JDBC-ODBC Bridge has been removed from Java (since Java 8) you should consider using the UCanAccess JDBC driver. It is a pure Java implementation so it works on non-Windows platforms, too.

For more information see

Manipulating an Access database from Java without ODBC

You should create a DSN(Data Source Name) first.

In control panel, if there is no drivers for accessing even though you have installed then there is a possibility that you may not getting odbcad32.exe file path. Choose your path from this, and then right click Data Sources(ODBC)[where you are creating DSN], and paste one of following path there.

  1. The 32-bit version of the Odbcad32.exe file is located at:

    %WinDir%\Windows\SysWoW64

  2. The 64-bit version of the Odbcad32.exe file is located at:

    %WinDir%\Windows\System32

and while accessing, do like this:

String url = "jdbc:odbc:dsn_name";
Connection conn = DriverManager.getConnection(url);
Mr J

change the statement:

String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + "d:\\program files\\project\\program\\inspection management system\\db1.accdb";

to:

String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + "C://program files//project//program//inspection management system//db1.accdb";
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!