我的密码怎么了?我想它在SQL中,但我不知道为什么。提前谢谢你

try{
    clsConnect c = new clsConnect();
    Connection conn = c.makeConnection();
    Statement statement = conn.createStatement();
    String display = "SELECT SUM(Amountpaid) from mofficetbl";
    ResultSet rs = statement.executeQuery(display);
    while(rs.next()){
        totalTF.setText(rs.getString("Amountpaid"));
    }
}
catch (SQLException e) {
    JOptionPane.showMessageDialog(null, e);
}

最佳答案

您正在选择SUM(amountpaid)并试图访问该列amountpaid,但该列实际上不存在于ResultSet尝试rs.getString(1)中,或者在选择为“cc>”中加上一个名称,然后执行SELECT SUM(amountpaid) as sum from msofficetbl

10-06 05:50