`
bsnopwantd
  • 浏览: 20742 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

jdbc transaction

阅读更多
Question:
Does "Connection.setAutoCommit(false)" mean "begin a transaction?"
Answer:
By default, JDBC connections start in autocommit mode. This means that every executed statement is treated as a separate transaction. A transaction is simply an operation that is irreversibly completed.

There are occasions where this default behavior is undesirable. Having every statement commited to the database can reduce performance. In addition, a set of statements may have dependencies such that previous statements should be undone if a succeeding statement fails. This is why the JDBC API provides the

Connection.setAutoCommit()
method. You can turn off the default autocommit behavior by calling this method with an argument of false. All statements executed afterward will not take effect until you call
commit()
Therefore, the first call of
setAutoCommit(false)
and each call of
commit()
implicitly mark the start of a transaction. Transactions can be undone before they are committed by calling
rollback()
You will typically rollback a transaction when one of its constituent statements fails.
分享到:
评论

相关推荐

    Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: ….. this is incompatible with sq

    1、写在开头 标题之前我想说一下Linux的mysql真的实在是太坑了。太坑了。总是会出现这样那样的你想不到的问题。崩溃了。首先来罗列一下我遇到过的...Cause:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorExcepti

    JDBC & Transaction 总结整理

    在JDBC中,事务(Transaction)管理是确保数据一致性、完整性和并发控制的关键部分。 1. **JDBC连接池配置** - **配置连接池**:在WebLogic等应用服务器中,JDBC连接池用于管理数据库连接,以提高效率和资源利用率...

    SSH框架优点及事务说明

    典型的J2EE三层结构,分为表现层... Hibernate是对JDBC的轻量级对象封装,Hibernate本身是不具备Transaction处理功能的,Hibernate的Transaction实际上是底层的JDBC Transaction的封装,或者是JTA Transaction的封装,

    Hibernate事务

    在 Hibernate 中,事务管理可以基于 JDBC Transaction 或 JTA (Java Transaction API) 进行,这两种方式各有特点。 首先,Hibernate 默认的事务处理机制是基于 JDBC Transaction。这意味着在进行数据库操作时,...

    MyBatis 事务管理解析:颠覆你心中对事务的理解!.docx

    在 JdbcTransaction 类中,事务的开始、提交和回滚实际上对应于 `conn.setAutoCommit(false)`、`conn.commit()` 和 `conn.rollback()`。`close()` 方法并不真正关闭事务,而是将连接返回到连接池中。这里值得注意的...

    前端-后端java的Util类的工具类

    │ │ │ frame-sourcefiles-org.apache.ibatis.logging.jdbc.html │ │ │ frame-sourcefiles-org.apache.ibatis.logging.jdk14.html │ │ │ frame-sourcefiles-org.apache.ibatis.logging.log4j.html │ │ │ ...

    ERRORLOG

    org.hibernate.TransactionException: JDBC rollback failed

    J2EE企业级项目开发-3期(KC007) 6.5 MyBatis的事务管理和缓存机制文档.doc

    MyBatis 会创建 `JdbcTransactionFactory` 实例,该工厂会创建 `JdbcTransaction` 对象,这个对象负责执行 JDBC 的事务操作。 2. **MANAGED 事务管理**:在这种模式下,MyBatis 不直接管理事务,而是依赖于应用...

    mybatis源码.rar

    源码中的`ManagedTransaction`和`JdbcTransaction`分别对应容器管理和手动管理两种模式。 6. 注解支持:MyBatis3引入了注解支持,使得在不写XML配置的情况下也能完成映射。`AnnotationBeanParser`类解析注解并生成...

    myBatis系列之七:事务管理

    MyBatis的事务管理涉及到Transaction接口和其实现类,如JdbcTransaction,它们协同工作以处理事务的生命周期。 通过以上讲解,我们可以看到MyBatis的事务管理机制不仅提供了灵活性,也确保了数据的完整性和一致性。...

    jdbc jdbc jdbc

    5. **事务(Transaction)管理**:JDBC支持ACID(原子性、一致性、隔离性和持久性)事务属性,确保数据的完整性和一致性。`Connection`对象提供了开始、提交和回滚事务的方法。 6. **批处理(Batch Processing)**...

    ibatis源码,ibatis源码 ibatis源码 ibatis源码

    在源码中,`org.apache.ibatis.transaction.jdbc.JdbcTransaction`和`org.apache.ibatis.transaction.managed.ManagedTransaction`分别对应JDBC和Spring的事务管理。 十、缓存机制 iBatis提供了本地缓存和二级缓存...

    hibernate 4.1.5 source code

    7. Transaction管理:`Transaction`接口定义了事务操作,其底层实现了JDBC的事务管理,如`JdbcTransaction`。 四、源码学习价值 深入研究Hibernate 4.1.5源码,不仅可以理解ORM框架的基本工作原理,还可以了解到...

    Hibernate实现原理模拟

    5. **事务处理**:Hibernate支持JTA(Java Transaction API)和JTAS(JDBC Transaction API),通过Session的beginTransaction和commit/rollback方法管理事务。 6. **缓存机制**:一级缓存是Session级别的,自动...

    hibernater 源代码

    在源代码中,`org.hibernate.Transaction`的实现类如`JDBCTransaction`处理了数据库事务的开始、提交和回滚。 3. **查询语言(HQL)和Criteria API** Hibernate 提供了自己的SQL方言——HQL(Hibernate Query ...

    hibernate3api

    2. Transaction:Hibernate支持JTA(Java Transaction API)和JTAS(JDBC Transaction API),提供了事务管理,确保数据的完整性和一致性。 3. Entity:在Hibernate中,实体是对数据库表的映射,通常是一个Java类,...

    Hibernate API

    - **Transaction**: Hibernate的Transaction接口是JDBC Transaction的封装,提供了一种更高级别的事务管理方式,支持自动提交和回滚。 2. **对象持久化** - **Entity**: 实体类是映射到数据库表的对象,通过@...

    mybatis入门基础案例demo

    - MyBatis 默认使用 JdbcTransaction 进行事务管理,可以通过 `<transactionManager>` 配置来选择不同的事务管理器。 - 事务的提交和回滚通常由 Spring 等框架自动管理,也可以手动调用 `SqlSession.commit()` 或 ...

    深入解析Java中的JDBC事务

    public static void jdbcTransaction(int id) { Connection conn = null; PreparedStatement pstmtUpdate = null; PreparedStatement pstmtQuery = null; String updateSql = "UPDATE table SET column=? WHERE...

    spring对jdbc的支持jar包

    5. **Transaction Management**:Spring提供了声明式事务管理,允许开发者在配置文件中声明事务边界,而不是在代码中显式管理。这样可以确保事务的正确性和应用程序的健壮性。 6. **DataSourceUtils** 和 **...

Global site tag (gtag.js) - Google Analytics