http://community.jboss.org/thread/147331
2010-1-27 上午8:21
Error: No ManagedConnections available within configured blocking timeout
- JBoss 4.2.3.GA
- JDK 5 Update 22
- Microsoft SQL Server 2000
- Microsoft SQL Server 2005 JDBC Driver 1.2 (compatible with MSSQL Server 2000)
- Windows Server 2003
Hello, everybody!
I have always had this error in JBoss, but I always ignored it deciding not to investigate it any further because it didn't happen very often (once a month in the majority of cases, but less than this in some cases. However yesterday it happened twice), because it was just a matter of restarting the application server, and because it was a very strange error. But now I realize that this error is simply unacceptable bacause it makes an application very unstable and unreliable, even though you are sure that there's nothing wrong in your application to cause it. I'm talking about this error:
org.jboss.util.NestedSQLException: No ManagedConnections available within configured blocking timeout ( 30000 [ms] ); - nested throwable: (javax.resource.ResourceException: No ManagedConnections available within configured blocking timeout ( 30000 [ms] ))
I can assure you that I'm not leaking any open database connection in my application. JBoss is configured to check if the application let a connection open and I don't get any message from JBoss telling me this. I'm also closing all ResultSets and Statements. I'm following the rules contained here:
http://community.jboss.org/wiki/CanJBossTellMeWhenIDontCloseAConnection
This is the pattern I use to close resources:
Connection connection = null;
PreparedStatement statement = null;
ResultSet data = null;
try
{
DataSource ds = get data source with JNDI
connection = ds.getConnection();
// ...
}
finally
{
if (data != null)
{
try
{
data.close();
}
catch (SQLException ex)
{
}
}
if (statement != null)
{
try
{
statement.close();
}
catch (SQLException ex)
{
}
}
if (connection != null)
{
try
{
connection.close();
}
catch (SQLException ex)
{
}
}
}
I really would like to have a solution to this problem.
Thank you in advance.
Marcos
---------------------------------------------------------------------------------------------------------------
Re: Error: No ManagedConnections available within configured blocking timeout
Ok, with two favorable posts suspecting that the problem is in the driver, I think I'll give a chance to it and test the open source driver. But I would like you to elaborate a little more why you think that official MS SQL Server driver has a problem with CallableStatements. Do you have any evidences about this? I really would like to hear from you about that. Anyway this is my datasource configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>BibliotecaDS</jndi-name>
<connection-url>jdbc:sqlserver://server;databaseName=DBTESEUS</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<user-name>user-name</user-name>
<password>password</password>
<min-pool-size>0</min-pool-size>
<max-pool-size>25</max-pool-size>
<idle-timeout-minutes>3</idle-timeout-minutes>
<new-connection-sql>SELECT 1</new-connection-sql>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>MS SQLSERVER2000</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
Marcos