java中JDBC的实际使用注意事项
连接被自动关闭:connection is close


如果你的jdbc写了这样的代码,就会出现第一次执行完次方法后自动关闭连接:

以下为编译后的class源代码

我的项目中使用连接池,所以连接不必关闭,有连接池做缓存。
可以更改为
try {
Connection conn = this.connection;
xxxxxxxx
} catch {
xxxxxxxx
}
连接被自动关闭:connection is close


如果你的jdbc写了这样的代码,就会出现第一次执行完次方法后自动关闭连接:

以下为编译后的class源代码

我的项目中使用连接池,所以连接不必关闭,有连接池做缓存。
可以更改为
try {
Connection conn = this.connection;
xxxxxxxx
} catch {
xxxxxxxx
}