0
I’m using the following code in a Thread:
try {
Class.forName("org.postgresql.Driver");
DriverManager.setLoginTimeout(60);
conexao = DriverManager.getConnection(url,usuario,senha);
}catch(Exception e){
mensagemErro = e.getMessage();
}
And in another Thread(GUI) has a window as cancel button, but I do not know how to cancel Drivermanager. connection is a public variable.
Would not resolve to close the connection?
– Pedro Teles
I am not an expert on the subject, but I recommend reading the two links http://stackoverflow.com/questions/295920/how-can-i-abort-a-running-jdbc-transaction http://blog.shinetech.com/2007/08/04/how-to-close-jdbc-resources-properly-every-time/ I hope I’ve helped.
– Jhonathan
No, I’d like to unlock the thread immediately
– Rodrigo Santiago
Recommendation of Soen, take a look here Apache Connections Pool
– user28595
I’m not actually using anything in the other Thread. It’s just to check the connection, but in case the user wants to cancel the test. I thought this would be something super simple :(
– Rodrigo Santiago
Apparently connecting objects are not Thread-safe, then sharing it can bring unexpected results in the application.
– user28595