-1
I have made a database of Bank Bank Accounts, each of these accounts has its own id
to identify, and has his tipo
, to know what type of account the user is accessing at that time, type, he can have a current account and salary, are two types of accounts associated with this , so I want to search my bank using the account id and the type that is whole too, but ta giving error.
Banco Conta = new Banco();
Conta.conectar();
ResultSet resultSet = null;
PreparedStatement preparedStatement = null;
String sql = "SELECT *FROM Contas WHERE NumeroConta = ? "
+ " AND Tipo = ?";
try{
preparedStatement = Conta.criarPreparedStatement(sql);
preparedStatement.setInt(1, getNumConta());
preparedStatement.setInt(5, getTipo());
resultSet = preparedStatement.executeQuery();
while(resultSet.next()){
System.out.println(" " + resultSet.getFloat("Saldo"));
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try{
resultSet.close();
preparedStatement.close();
Conta.desconectar();
}catch(SQLException ex){
ex.printStackTrace();
}
}
That is the mistake:
Exception in thread "main" java.lang.NullPointerException
at Usa.Busca.Trans(Busca.java:135)
at Principal.main(Principal.java:82)
/home/nathan/.cache/netbeans/8.2/executor-snippets/run.xml:53: Java returned: 1
That is the method
Usa.Busca.Trans(Busca)
? If so, which is line 135?– Victor Stafusa