数据库操作代码:
// Load JDBC driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dbUrl = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};
DBQ=access\test.mdb";
Connection con = DriverManager.getConnection(dbUrl, "", "");
Statement state = con.createStatemen(ResultSet.TYPE_SCROLL_SENSITIV
E,
ResultSet.CONCUR_UPDATABLE);
// 执行 SQL语句
String sql = "select * from score";
ResultSet rs = state.executeQuery(sql);
displayResultSet(rs);
rs.close();
state.close();
con.close();
将数据显示在表格中:
private void displayResultSet(ResultSet rs) throws SQLException {
评论0
最新资源