Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: How to connect to a database via JDBC-ODBC (Microsoft Access)

Java: How to connect to a database via JDBC-ODBC (Microsoft Access)
{filelink=7018}

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class ODBC_Connection
 {
  public static void main(String args[]) throws Exception
  	{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn = DriverManager
        .getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=c:/test.mdb");
    Statement stmt=conn.createStatement();
    ResultSet res = stmt.executeQuery("select ID, company from Customers");
    while (res.next())
    {
      System.out.println(res.getString("Company"));
    }
    conn.close();
  }
}

Users who found this page were searching for:

  • crypt python des
  • java swing underline text
  • dictionary with objects python

No comments yet.

Leave a Comment