Reputation: 21
When the class conector.conexion();
if I use the command:
if (conector.conexion()) {
}
Error : Required Boolean `conector.conexion()`
What is wrong?
Upvotes: 0
Views: 138
Reputation: 3056
Connection is not Boolean type class.
Instead of if(conector.conexion())
you can use like below :
if(conector.conexion() != null) {
//It ensure connection is not null
//To check connection is not closed
if(!conector.conexion().isClosed()) {
//code...
}
}
For Detail: Connection Docs
Upvotes: 1
Reputation: 8146
Do following to check if connection instance has been created or not:
if(conector.conexion() != null){
//code stuff
}
Upvotes: 0