Author Message
MichaelNorman
Joined: Jun 3, 2015
Messages: 448
Offline
I'm troubleshooting an issue where I am intermittently getting the "Could not retrieve connection info from pool" error. I've played around with the connection string properties in context.xml, but not having much luck getting it corrected. The odd thing is that this application has much less volume than the other applications we run, and this is the only application with an issue.

Is there a way for me to programmatically acquire connection to the existing database connection pool via org.apache.tomcat.dbcp.dbcp.datasources.PerUserPoolDataSource element, and how would I do that? The only thing that I seem to be able to do is instantiate a new instance by using new PerUserPoolDataSource.

I'd like to be able to utilize getNumActive and getNumIdle and log those for troubleshooting purposes.
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Have you played around with parameters like validationQuery, testOnBorrow, testOnReturn? That's what I have been suggesting to people. You shouldn't need to do any custom code.

https://commons.apache.org/proper/commons-dbcp/configuration.html
MichaelNorman
Joined: Jun 3, 2015
Messages: 448
Offline
Yes those are the settings I have been playing with. When I started getting this I was using the exact same default parameters that are in place when you export your war file as all of my other applications. What is really baffling is that as I said before this application is 1/10th of the volume as our larger applications and is the only one with an issue.

Right now I'm using the below, but it does not appear to help. Also yes I did start with a real validationQuery against my DB, but read online select 1 is a valid validation query for MS SQL.


<Resource auth="Container" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" factory="org.apache.tomcat.dbcp.dbcp.cpdsadapter.DriverAdapterCPDS" name="jdbc/TelecomNCOCPDS" type="org.apache.tomcat.dbcp.dbcp.cpdsadapter.DriverAdapterCPDS" url="jdbc:sqlserver://SERVER;databaseName=DATABASE"/>

<Resource auth="Container" dataSourceName="java:/comp/env/jdbc/TelecomNCOCPDS" defaultMaxActive="10" defaultMaxIdle="5" defaultMaxWait="10000" factory="org.apache.tomcat.dbcp.dbcp.datasources.PerUserPoolDataSourceFactory" logAbandoned="true" name="jdbc/TelecomNCO" removeAbandoned="true" removeAbandonedTimeout="300" testOnBorrow="true" type="org.apache.tomcat.dbcp.dbcp.datasources.PerUserPoolDataSource" validationQuery="select 1"/>


I was attempting to get at the real active and idle connection numbers so I can see what tomcat is actually doing on all these calls.
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
I would suggest trying a different query like "select <column> from <table>"
MichaelNorman
Joined: Jun 3, 2015
Messages: 448
Offline
Yes we started out with an actual query such as that. I would like to know how we can programmatically access the connection pool that OD has opened via the DBOP. Is that possible?
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
You have to see what particular API the Tomcat/Apache DBCP provides. There is no standard API for that. The standard JDBC API that OD uses limits to getting a connection from the cool. Providing a connection is in the implementation of the app servers. OD has to work with the standard to support different app servers.
MichaelNorman
Joined: Jun 3, 2015
Messages: 448
Offline
I might be onto something. I noticed that this database connection has the same name as another application's database connection. I would not think this would cause an issue. I renamed it and have not seen another error crop up yet. If I have two apps with the same connection name is that a concern? Do different apps have to maintain different names for their database connections?
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
You mean the datasource names are the same? That could be a problem. The datasource name is part of the JNDI. That is the identifier to the connection pool. I am surprised Tomcat/DBCP couldn't detect the duplication at startup when they are defined in different application web.xml with the same name.
MichaelNorman
Joined: Jun 3, 2015
Messages: 448
Offline
Yes that's correct. The datasource names were the same. Ok I will continue to monitor, but fingers crossed, we are ok for now.

Thanks Wilson!
Go to:   
Mobile view