Exception occurred during event dispatching: java.lang.NullPointerException
Hello to all!!!
Can anibody help me with this problem, i'm getting a null pointer exception in this part of the code:
-----------------------------------------------------------------------
public boolean findBranch(Integer iddespesa)
{
try
{
con = AccessConection.getInstance().getConnection();
ps = con.prepareStatement("SELECT iddespesa FROM despesas where iddespesa = ? " );
ps.setInt(1,iddespesa);
ResultSet rs = ps.executeQuery();
if (rs.next())
{
return true;
}
else
{
return false;
}
}
catch (SQLException ex)
{
ex.printStackTrace();
return false;
}
}
-------------------------------------------------------------
DB connection:
public boolean connect(String username, String password) throws ClassNotFoundException
{
try
{
String url = "jdbc:mysql://localhost:3306/OrcDataBase";
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(url, username,password);
System.out.println("connected");
con.setAutoCommit(false);
return true;
}
catch (SQLException ex)
{
return false;
}
}
I can make a connection to mysql database, because i can see a process running with th user that i make the connection but when i make the call to the select it generates the error "Exception occurred during event dispatching:java.lang.NullPointerException".