0
I have the following code to store the maximum value of a column in a variable integer codemax:
cf = new ConnectionFactory().getConexao();
int codigomax = 0;
try {
stmt1 = cf.prepareStatement("SELECT max(id_endereço) as max_id_endereço from endereço");
rs1 = stmt1.executeQuery("SELECT max(id_endereço) as max_id_endereço from endereço");
if (rs1.next()) {
codigomax = rs1.getInt("max_id_endereço");
}
}
catch (SQLException ex){
}
But when I check the variable, it always has the value that was initialized PS: The column in question has data!