日期:2014-05-20 浏览次数:21179 次
public static void main(String args[]) { String name; Connection conn = null; Statement stmt = null; ResultSet rs = null; try { Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } try { conn = DriverManager.getConnection( "jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=E:\\hib.mdb"); stmt = conn.createStatement(); rs = stmt.executeQuery("select top 5 * from test1"); while (rs.next()) { name = rs.getString("NAME1"); System.out.println("==="+name+"==="); } conn.close(); } catch (SQLException w) { System.out.println(w.getMessage()); } }