0

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?

2
  • when you say reconnect, do you mean a closed connection? Commented Mar 4, 2013 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. Commented Mar 4, 2013 at 23:58

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.