I want to take the value of total sum of a column and display it in a textfield.
I used this code but it's not working.
public static String invoice() throws SQLException{
Connection con = connect();
String query="SELECT SUM(costM) AS totalsum from Meals";
Statement s =con.createStatement();
s.execute(query);
ResultSet rs=s.getResultSet();
String result =rs.getString("totalsum");
return result;
}
//Method to apply when button clicked
public void message() throws SQLException{
textinv.setText(db.invoice());
}