I am trying to make a query on my GUI through a database, adding to the database is fine, but making a query through the GUI gives me a
"Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException" error
and I cannot figure out why. 4th line here is the first error it is giving me.
String category=categories[searchCategory];
    try {
        PreparedStatement stmnt = null;
        stmnt = con.prepareStatement("SELECT * FROM Jobs WHERE " +category + 
" LIKE '%?%')");
        stmnt.setString(1,searchingFor);
        System.out.println(stmnt.toString());
        ResultSet result = stmnt.executeQuery();
        while (result.next()) {
            for (int i=0; i<categories.length; i++){
                String field=categories[i];
                System.out.println(result.getString(field));
            }
        }
    } catch (SQLException e) {
        System.out.println("Error during select query " + e);
        e.printStackTrace();
    }
}
This is the createSearchTab code that it is saying  i have an error at.
excelReader.search(category, searchingFor);
where is the NullPointerException?
 
    