Using JDBC with a Microsoft Access Database and ODBC

Step One, Create a New Database

Create a new database from within Access.

Just click on the blank database as follows:

We will call this database My Database.

Step 2 Create a new Table

Create a new table in the Datasheet view as shown below.

Step 3 Design your Table

Click on the go away box and click on the design view. The table is called MyTable (note no spaces in the name MyTable to access it in the Java code).

Step 4 Entering information in the Database

When you have finished entering in the required fields for teh database, click on the go away box and then double click on the name MyTable. The data can then be entered into the database. Some sample data is shown below. Once all the data is entered the database can be saved close Microsoft Access.

Step5 Creating a new ODBC Data Source

The ODBC Control panel by double clicking on it. Once it is open create a new Data Source by clicking the Add button then select the driver shown below and click on the Finish button.

Click on the Select button and select the  MyDatabase.mdb  file and click OK. (This is the database we created in Access).

Step 5a Naming the Database

The Data Source Name is the name of the database which is accessed in your code. The description is just a general description of what the datbase is about and does not relate to the Java code.

Step 6 The Java Program

We can now create a Java program which can access the odbc source.  A sample program which makes use of the Database we created is here .

Congratulations You've Now Finished The Tutorial:)