用jdbc-odbc桥,说白了就是,使用的数据库驱动程序变一下,其它的方式方法都一样

解决方案 »

  1.   

    jsp怎么访问Access数据库?为什么这么搭配?大骡子拉小车
      

  2.   

    import java.sql.*;public class test{
    public static void main(String[] args){
    //Authors
    try{
    String dbname="/TEMP/BIBLIO.MDB";
    String dbinfo = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+dbname;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn = DriverManager.getConnection(dbinfo);
    Statement stmt = conn.createStatement();
    ResultSet RS = stmt.executeQuery("SELECT * FROM Authors");
    while(RS.next()){
    System.out.println(RS.getString(2));
    }
    RS.close();
    RS=null;
    stmt.close();
    stmt=null;
    conn.close();
    conn=null;
    }
    catch(java.lang.Exception e){
    System.err.println(e);
    }
    }
    }