Ive been trying to validate values from Database.
so the scenario is,
if my
int id=1234;
PreparedStatement st= null;
Connection con =null;
con=DriveManager.getConnection(//details here);
String query ="SELECT ID FROM VAULT WHERE NUM=?";
st= con.prepareStatement(query); <------ NULLPOINTEREXCEPTION
st.setInt(1,id);
rs=st.executeQuery();
while(rs....)
{
String checker = rs.getString("ID");
}
if(checker.isEmpty() || checker ==null){
...//code here
}
PROBLEM: how to handle and store NULL value on the String checker? how to retrieve NULL value to be used on validation?
Program is stopping on prepareStatement as it is getting NULLPOINTER Ps: the query is returning NULL actually, and i need that NULL value for checking. so If it is NULL, i will do INSERT to that table.