Sponsered Links
Categories
Sponsered Links

JDBC SELECT query with MS-Access Database

 

This example shows how to run the SELECT query with the MS-Access Database.

import java.sql.*;
import java.io.*;

class SelectQuery{
    public static void main( String argv[] ){
        try{
            Class.forName ("jdbc.odbc.JdbcOdbcDriver");
            String url = "jdbc:odbc:msaccessdb";
            Connection dbcon = DriverManager.getConnection (url, "","");
            String queries = "select * from emp";
            Statement smnt = dbcon.createStatement( );
            ResultSet res = smnt.executeQuery( queries );
            boolean more = res.next();
            while ( more ){
                System.out.println( "Col1: " + res.getInt( "col1" ));
                more = res.next();
            }
        } catch (java.lang.Exception ex) {
            System.out.println( "** Error on data select.** " );
            ex.printStackTrace ();
        }
    }
}

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved