MS Access JDBC Driver -- Connecting MS Access with Java
To connect Java with MS Access, you need a JDBC driver. Although Microsoft do not produce a JDBC driver for MS Access, Easysoft provide two Microsoft Access JDBC drivers. Use these JDBC drivers to provide the connectivity layer between your Java code and MS Access database.
Accessing MS Access from Java
This tutorial shows how to access MS Access databases from Java.
Configuring the Microsoft Access ODBC Data Source
You will find the ODBC Administrator within Administrative Tools from your Control Panel.
From here you will create your new System DSN. Click the Add button and then select the Microsoft Access Driver and click Finish.
Give your DSN a meaningful name and click Select. Here you will be able to browse to your existing .mdb file.
Once you have selected the database you want to access, click OK and then OK again to exit the dialog box. You have now created your data source.
Running the Demo Applet
Within your services manager, make sure that the JOB service is running, and then open a web browser and go to the following URL http://localhost:8031.
This will open the JOB Web Administrator where you have many configuration options. On the left hand side, you will see a Test Applet link. This will show you a box with various parameters. The Logon User and Password should be the same as your valid Windows details.
Once you have entered your username and password, click the Connect button. This will then display a pop-up box:
As you can see from the image, we have created a system DSN that points to northwind.mdb called NORTHWIND. (There is a Northwind database included in most versions of Microsoft Office.) If you have more than one system DSN, your newly created DSN will appear at the bottom of the drop down list.
From here, simply select the DSN you wish to connect to and click Connect. (You will not need to add a database username and password as the Access database will use NT authentication.)
Once connected, you will see a list of tables. You can issue a simple
select * from table by double clicking the table you wish to query. Alternatively, you can issue your own SQL in the SQL field.
This will return the result set in an applet window:
Running the Demo Application
To run the Demo Application, choose Start > Programs > Easysoft > JDBC-ODBC Bridge > AWT Application Demo.
This should now display the demo application:
You can see that the connection URL already has the first part of the connection string in it --
The complete connection string should take the form of:
From here, you do not need to add any further details. Simply click Connect.
From here, you will be able to see a list of tables from your Access database. The same applies to the SQL commands as it does in the Demo Applet section. Simply issue your SQL command and click Submit.
Why can’t I connect to my Microsoft Access .mdb file using the Easysoft JDBC-ODBC Bridge?
The problem is likely to be that the Microsoft Access .mdb file is on a mapped network drive that can only be accessed by a named user.
There are three possible solutions:
Why do I get error "[JOB] Connection failed[JOB] RPC Exception: access denied (java.net.SocketPermission ip address/server name:8031 connect,resolve)" when trying to connect in the test applet using a fully qualified JDBC URL?
If you have run the test applet from the Start menu, the browser will default to 127.0.0.1 (localhost). This will then be the only IP address/server name you will be able to use in your JDBC URL. You will not be able to use the server’s actual IP address/server name unless you have used either of them in your initial browser address (http://ip address/server name:8031).
Why do I get error "RPC Exception: access denied java.net.SocketPermission" in the JOB applet?
Check that your JDBC connection URL is connecting to the same machine as your browser. For example, http://127.0.0.1:8031 is not the same as the machine name / IP address, so in your connection URL it must match:
Why do I get the error "Client denied access due to access control rule"?
The machine you are running the JOB JDBC driver on has attempted to connect to the specified server (where the JOB Server is running) but there is an access control rule on the server that denies your client access. You need to use the JOB web administration interface to examine the access control rules. Point a web browser at:
Then select Security. The access control rules are defined on this page.
Microsoft Access ODBC Driver
Easysoft also produce an MS Access ODBC driver for Linux and Unix platforms.