Amazing technological breakthrough possible @S-Logix

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • +91- 81240 01111

Social List

How to do database connectivity using java for MS-Access database?

Description file presents the Connectivity code for database. It initially loads the diver (“sun.jdbc.odbc.JdbcOdbcDriver”) and creates the connection with the database using DSN (“user”). Then statement object is created for the established connection that executes the query (“select”) mentioned and produces the result of query execution (ResultSet).

Sample Code
  • Filename:

import java.sql.*;
class MsAccessTest {
public static void main(String args[]) {
String username="";
String password="";
try {
// loading driver
// Connection set up with database with dsn name as user
Connection c = DriverManager.getConnection("jdbc:odbc:user",username,password);
// Creating statement for the connection to use sql queries
Statement st = c.createStatement();
// Executing sql query using the created statement over the table user_details located in the database pointing by the dsn
ResultSet rs = st.executeQuery("SELECT * from user_details");
// Accessing the result of query execution
username = rs.getString(1);
// Closing the statement and connection
catch (Exception e) {