通过jdbc 连接 Access

import java.sql.*;

public class Access

{

public static void main(String args[])

{

try

{

String strurl="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=books.mdb";

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

Connection conn=DriverManager.getConnection(strurl) ;

Statement stmt=conn.createStatement();

ResultSet rs=stmt.executeQuery("select * from books");

if(rs.next())

{

System.out.println(rs.getString("简介"));

}

}catch(Exception e)

{

System.out.println(e);

}

}

}

posted on 2009-05-08 15:08  李超@hicc  阅读(719)  评论(0编辑  收藏  举报

导航