LocalDataSourceConnectionProvider checks against SmartDataSource before closing a Connection

Issue: SPR-9978
This commit is contained in:
Juergen Hoeller
2012-11-08 23:37:14 +01:00
parent 4ed9ababdf
commit d6e1a4a26a
2 changed files with 19 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,8 @@ import org.hibernate.HibernateException;
import org.hibernate.connection.ConnectionProvider;
import org.hibernate.util.JDBCExceptionReporter;
import org.springframework.jdbc.datasource.DataSourceUtils;
/**
* Hibernate connection provider for local DataSource instances
* in an application context. This provider will be used if
@@ -87,12 +89,12 @@ public class LocalDataSourceConnectionProvider implements ConnectionProvider {
}
/**
* This implementation simply calls <code>Connection.close</code>.
* @see java.sql.Connection#close()
* This implementation calls {@link DataSourceUtils#doCloseConnection},
* checking against a {@link org.springframework.jdbc.datasource.SmartDataSource}.
*/
public void closeConnection(Connection con) throws SQLException {
try {
con.close();
DataSourceUtils.doCloseConnection(con, this.dataSourceToUse);
}
catch (SQLException ex) {
JDBCExceptionReporter.logExceptions(ex);