且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

提交事务后Spring是否关闭连接?

更新时间:2022-12-18 13:13:39

Spring 会在事务完成时调用 close(),这可能来自提交或回滚.close() 是否真正关闭真正的 JDBC 连接取决于 DataSource 配置.如果它是一个普通的 JDBC 连接,那么它实际上会关闭.如果它是一个连接池,那么它可能会在关闭时返回到池中.

Spring calls close() when the transaction finishes which could be from either a commit or rollback. Whether or not close() actually closes a real JDBC connection depends on the DataSource configuration. If it's a plain JDBC connection, then it will actually close. If it is a connection pool then it will probably just be returned to the pool on close.