简体   繁体   English

jdbc executeUpdate在自动提交模式下失败

[英]jdbc executeUpdate fail in autocommit mode

in autocommit mode on postgresql database, if jdbc executeUpdate throws SQLException it means that no data on database was modify? 在自动提交模式下,在PostgreSQL数据库上,如果jdbc executeUpdate抛出SQLException,则意味着数据库上的任何数据都没有被修改? or i should set autocommit to false and manage it manually? 还是我应该将autocommit设置为false并手动进行管理?

When a connection is created, it is in autocommit mode. 创建连接后,它处于自动提交模式。 This means that each individual SQL statement is treated as a transaction and is automatically committed right after it is executed. 这意味着每个单独的SQL语句都被视为事务,并在执行后立即自动提交。 This is true for all JDBC drivers, including the PostgreSQL's one. 对于所有JDBC驱动程序(包括PostgreSQL的驱动程序)都是如此。 To start a new transaction, we turn the autocommit off. 要开始新的交易,我们关闭自动提交。

To read more and for sample code, check: http://zetcode.com/db/postgresqljavatutorial/ 要了解更多信息和示例代码,请查看:http: //zetcode.com/db/postgresqljavatutorial/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM