Reputation: 71
I have the following Code that throws a null pointer exeption
public void checkAcc(String sql)
{
System.out.print(sql); // the statement executed is "SELECT AccountID FROM BankAccount"
try {
stmt.executeQuery(sql);
} catch (Exception e) {
System.err.println("Nope that is broken - " + e);
}
}
Upvotes: 0
Views: 93
Reputation: 3652
Have you checked to ensure that stmt
isn't null? The way that function is written, it must be a field, and you have to make certain that it has been initialized before checkAcc()
is called.
Upvotes: 2