[Solved] Null Pointer Exception during MySQL database write


Check documentation of ResultSet.getString:
http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.html#getString%28int%29

String getString(int columnIndex) throws SQLException

Returns:
the column value; if the value is SQL NULL, the value returned is null

According to this your code is vulnerable to null pointer exception at following places:

   if (!results.getString("level").isEmpty()) {                
    .......
   } else if (!results.getString("thesisTitle").isEmpty() ||
          !results.getString("thesisAdvisor").isEmpty()) {  
   ..........
   } else if (!results.getString("company").isEmpty()) {     
   ............

If any of these column contain null value, then getString( .. ) returns null, and because of this getString( ... ).isEmpty() throws null pointer exception.

solved Null Pointer Exception during MySQL database write