-1
I want to display in the java swing graphical interface the total number of users registered there in my database Look what I tried
He of error null
public void restt() {
String sql = "select count(id) from login";
try {
pst = conexao.prepareStatement(sql);
Long quantidade = rs.getLong(1);
resu.setEnabled(false);
resu.setText(String.valueOf(quantidade));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Erro: " + e.getMessage());
}
}
Thank you for your attention, I ask for your help.
"the total number of users" ever tried to use a
select count(id)
? but this has nothing to do with the question title, edit and make clearer what you really want– Ricardo Pontual
Joptionpane.showMessageDialog is inside the catch block (when an exception occurs). This is not wrong?
– leandro.dev
Hello Matheus, Observing your code I noticed that it is missing to create the used resultset (rs). For this you can add a line after declaring the pst with the following code "Resultset rs = pst.run();"
– ooredroxoo