am getting the error shown from this code: enter image description here
private void formComponentShown(java.awt.event.ComponentEvent evt) {
try{
Connection conn = ConnectionProvider.getCon();
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select max(pId) from product");
if(rs.first()){
int id = rs.getInt(1);
id = id+1;
String str = String.valueOf(id);
jLabel4.setText(str);
}
else{
jLabel4.setText("1");
}
}
catch(Exception e){
JOptionPane.showMessageDialog(null,e);
}
}
i wanted the code to change text on the label from 100 to whatever that was largest value in an id column in product table of a database. the code was to increase that value after new data is entered and keep that as it's current value