![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据库
印贤卓
这个作者很懒,什么都没留下…
展开
-
try-with-resource手动rollback
在用try-with-resource管理链接资源时,catch块中无法访问到connection,也就无法手动回滚 try (Connection con = createConnection()){ con.setAutoCommit(false); Statement stm = con.createStatement(); stm.execute(someQuery); // causes SQLException }catch(SQLException ex){ // 注原创 2020-07-01 16:09:21 · 884 阅读 · 0 评论 -
mybatis插入数据到sqlserver报异常The statement must be executed before any results can be obtained.
这是因为sqlserver并不会自动返回插入数据自动生成的自增主键,如果在mybatis的insert语句中添加了 useGeneratedKeys="true" 这会要求mybatis返回主键,但sqlserver并不支持,结果就报异常。 去掉该代码即可。 ...原创 2020-06-30 12:44:23 · 3635 阅读 · 3 评论