Take the 2-minute tour ×

I am working on program in Java that can connect to PostgreSQL multiple databases. Problem occurs when I want to reconnect to other database on the same server. I am using JDBC postgresql driver and whenever I try to close old connection and create new I get an exception:

org.postgresql.util.PSQLException: Something unusual has occured to cause the driver to fail. Please report this exception.

Is there any way to reconnect to other database?

share|improve this question
when you say reconnect, do you mean a closed connection? –  John Kane Mar 4 '13 at 21:31
Without seeing the code you're using and the full, exact text of the error message and associated stack trace, it's nearly impossible to say. –  Craig Ringer Mar 4 '13 at 23:58
add comment

2 Answers

I'd recommend creating the connection when you need it and closing it when you're done in the narrowest scope possible.

I'd also advise you to set up connection pools, one for each database you might connect to.

share|improve this answer
add comment
up vote 0 down vote accepted

I didn't notice that there is another exception under the first one. The second exception was the real problem. I was running reconnecting on main thread. Putting it in the own thread solved the problem.

share|improve this answer
add comment

Your Answer


