My program was working fine until i introduced the if statement, without this "if" there are (java.lang.NullPointerException) errors .
What shall i do?
Thank you in advance .
Here is the necessary part of code for you:
Connection c ;
Statement stmt =null ;
if (c != null) {
try {
stmt = c.createStatement();
String sql = "INSERT INTO Mytable (age,name,salary) VALUES ( ?,?,? )";
PreparedStatement pst = c.prepareStatement(sql);
pst.setInt(1, 38);
pst.setString(2, "Jim");
pst.setInt(3, 900);
stmt.execute(sql);
stmt.close();
c.commit();
c.close();
} catch (SQLException exp) { exp.printStackTrace();}
System.exit(0); }}}