62,614
社区成员
发帖
与我相关
我的任务
分享
/**
* Releases this <code>Connection</code> object's database and JDBC resources
* immediately instead of waiting for them to be automatically released.
* <P>
* Calling the method <code>close</code> on a <code>Connection</code>
* object that is already closed is a no-op.
* <P>
* It is <b>strongly recommended</b> that an application explicitly
* commits or rolls back an active transaction prior to calling the
* <code>close</code> method. If the <code>close</code> method is called
* and there is an active transaction, the results are implementation-defined.
* <P>
*
* @exception SQLException SQLException if a database access error occurs
*/
根据上面的API,事务在连接关闭时是否回滚都完全取决于实现类,至于其他对象更是没提。
个人观点,你这样做完全是寄希望于数据库驱动JAR包的作者比较有良心,还是不要偷懒的好。