I want to know if a connection is valid, this is an example of what I'm trying to do:
EnterpriseConnection connection = new MyEnterpriseConnection();
System.out.println("first " + connection.getUserInfo());
connection.logout();
if(connection == null){
connection = new MyEnterpriseConnection();
}
System.out.println("second" + connection.getUserInfo());
The first System.out is printed but the second is not because is not getting in the if condition, my question is: what is the condition i should use to validate if a connection is logged out to create a new one. I was looking for a method like isValid() or something like that in the EnterpriseConnection class but it isn't
new EnterpriseConnection().getUserInfo()
in a try/catch should do that. If it is the latter you need to keep a reference to that connection and use thatconnection.getUserInfo()
in a try/catch.