Skip to Content
author's profile photo Former Member
Former Member

EP - Database Connection

Hi All,

I just want to access an External MS Acess Database Table. How to create the Connection and how to access the table. Can any one help me to do this...

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Oct 18, 2005 at 12:38 AM

    Hi Riju,

    You can use ODBCJDBC connection to connect to MS ACCESS DATABASE.

    To download the jdbc driver http://java.sun.com/products/jdbc/download.html

    try

    {

    // Step 1. Load the Type 1 database driver:

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    // Step 2. Create a connection to the database

    // using pre-defined Data Source:

    Connection con = DriverManager.getConnection

    ("jdbc:odbc:Datasourcename",userid,password);

    // Step 3. Create a Statement object:

    Statement stmt = con.createStatement();

    // Step 4. Build and send the database SQL query:

    String query = "SELECT * FROM DataTable";

    // Step 5. Get the resultset from the database:

    ResultSet rs = stmt.executeQuery(query);

    // Step 6. Process the data:

    // ...

    }

    // Microsoft Access returns this exception if the ResultSet

    // object is not closed before another query is executed:

    catch (SQLException se) {

    {

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.