It's pretty self-explanatory; somewhere you close a Statement then try to use it again. Check the method "com.mycompany.myapp.FontDB.getMetrics" and see where you might be using a statement that you previously closed.
it seems like I am experiencing a similar problem. Mine however works when there is only one thread accessing the function. However, when multiple threads hit it at the same time, I constantly start receiving the error. I wonder if you could fix the problem?
My function is defined as synchronized, so it is very unlikely that threads interfere to one anothers job. any idea?
Thanks a lot Jeanne for the reply and thanks for welcoming me
I wonder if it is a good practice to keep on opening and closing the connection as it is often the case the opening connection to the DB imposes extra overhead to the system as it requires a TCP handshake with the mysql server. In our case performance is an issue, so my preference would be to not even bother with opening and closing the connection to the DB, but to simply leave it open.
However, in that case, I face more disruptions when polling from the DB. Do you, or anybody in the forum, know of best practices for allowing access to the DB in multi-threaded environments? It would be a great help if someone could kindly refer me to such a resource.
author & internet detective
If you use a connection pool like dbcp, the overhead is minimal since the connection isn't closed - merely returned to the pool. Even if you only have one connection in your pool, I recommend this approach for a multi-threaded application. Especially one that has a lot of connections opening and "closing."
Your performance is likely to be better with a pool than your current approach too.
Joined: Sep 17, 2009
I am using DBCP already, but my environment is a bit tricky as I am developing everything on top of OSGi.
One problem that I am facing right now is that the connections in the pool for DBCP get timed out after a while of sitting idle. I am using a JDBC implementation of DBCP, I wonder if there is any way to validate the connections in a pool to somehow abandon the obsolete ones?
subject: No operations allowed after statement closed.