Java connectivity link

Question Description

Get me connecity link to connect MS Access ( 2007) with Java

Final Answer

Accessing any database with Java is simple. For connecting with MS access, you have to configure and use JDBC-ODBC bridge.

First you have to configure ODBC to connect to your MS Access database

1. Open control panel\Administrative tools\Data sources (ODBC)

2. Click "Add" and select "Driver do Microsoft Access (*.mdb) and click "Finish"

3. Give the datastore name - this is the name you will be using in your java program

4. Click "Select" to browse for your database and select the file

5. Finish the wizard by clicking "OK" button

Thats it! Below is the code snippet which shows how to connect to MS Access database

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //Load Driver
Connection con = DriverManager.getConnection("jdbc:odbc:db_name"); 
Statement s = con.createStatement(); // Create Statement
String query = "select * from Data"; // Create Query
s.execute(query); // Execute Query
ResultSet rs = s.getResultSet(); //return the data from Statement into ResultSet
while(rs.next()) // Retrieve data from ResultSet
  System.out.print(rs.getString(1)); //1st column of Table from database
  System.out.print(rs.getString(2)); //2nd column of Table
System.out.print(rs.getString(3)); //3rd column of Table
  System.out.println(rs.getString(4)); //4th column of Table

Let me know if you need anything else, Cheers!

fixit (96)
Cornell University

Solid work, thanks.

The tutor was great. I’m satisfied with the service.

Goes above and beyond expectations !


Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors