0

I have code that connects to a SQL DB and queries it based on user input. I would like to connect using a Pool instead to speed up the query times. I attempted to write a Pool and Manager class but I am getting an unreported NamingException when I try to get a connection from the pool. I have also already caught NamingExceptions in my getConnection() function.

Does anyone know why I am getting this error?

Or could point me in the right direction to create a valid ConnectionPool?

1
  • Connection pooling isn't going to help the overall query operations performance that much, if at all. The rule with DB connections is "Open as late as possible, close as early as possible". Commented Nov 3, 2011 at 17:53

2 Answers 2

1

You should use the latest JDBC driver, which supports connection pooling internal, so you don't have to write your own.

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

1 Comment

@cbj: Is there some reason why that isn't working or can't be used?
0

You have 3 options:

  • If your code runs in an application server, configure a connection pool in the server.
  • Some JDBC drivers provide a connection pool implementation (but many only provide a poolable data source that is meant for integration with an app server).
  • Use commons-dbcp or some equivalent library to create a connection pool.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.