我是Java新手。我想查询Sale
表中的重复qty
并使用SQL group by
查询对其进行总结,并将结果存储在JTable中。
以下是我的代码无效。我该如何修复此代码?
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Driver={Microsoft Access Driver " +
"(*.mdb, *.accdb)};DBQ=C:\\SNDatabase1\\dist\\lib\\db11.accdb";
Connection con = DriverManager.getConnection(url);
Statement stt = con.createStatement();
String q = "SELECT ID,SUM(Qty)FROM Sale GROUP BY ID";
ResultSet rss = stt.executeQuery(q);
while(rss.next()) {
jTable7.setModel(DbUtils.resultSetToTableModel(rss));
}
} catch (Exception e) {
}