我想通过使用Access数据库中的java来计算行数。虽然,我使用Microsoft Access的查询设计,我在Access中得到答案,但当我把它写入Java程序时,我看到错误。这是我的代码:
private void TotalR() {
String sql = "SELECT Count([Requirements].[Requirement_ID]) AS R_List FROM Requirements;";
try {
st = con.prepareStatement(sql);
rs = st.executeQuery();
while (rs.next()) {
global.RNUM = rs.getString("R_List");
JOptionPane.showMessageDialog(null, global.RNUM);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}