I have an if statement I have checked with breakpoints that my program is entering the if statement and it is. I can follow through my statement till I get to the prepare statement line then my if statement appears to break out for no reason and not executing any code under my prepare statement. I have searched for my issue and can’t get any solutions.
if(entry != null && subNum.equals(1) && rs.getRow() == 1)
{
String blogID = rs.getString(1);
String timeStamp = rs.getString(2);
java.util.Date date= new java.util.Date();
String tStamp = new Timestamp(date.getTime()).toString();
query = "INSERT INTO blog_entries VALUES (?, ?, ?, ?, ?)";
ps = con.prepareStatement(query);
ps.setString(1, entry);
out.print(entry);
ps.setString(2, timeStamp);
out.print(timeStamp);
ps.setString(3, tStamp);
out.print(tStamp);
ps.setString(4, entry);
out.print(entry);
ps.setString(5, blogID);
out.print(blogID);
ps.executeUpdate();
out.println("Submit Successful");
}
The out.prints are there just for debugging purposes, any help would be appreciated.
I guess
conis not initiated if its breaking on the 1st use of it, can u confirm it is not null at the line its used? if yes catch and post the exception like: