com.j256.ormlite.dao.Dao.isAutoCommit()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中com.j256.ormlite.dao.Dao.isAutoCommit()方法的一些代码示例,展示了Dao.isAutoCommit()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.isAutoCommit()方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:isAutoCommit

Dao.isAutoCommit介绍

[英]Return true if the database connection returned by the #startThreadConnection() is in auto-commit mode otherwise false. This may not be supported by all database types.
[中]如果#startThreadConnection()返回的数据库连接处于自动提交模式,则返回true,否则返回false。这可能不是所有数据库类型都支持的。

代码示例

代码示例来源:origin: j256/ormlite-core

/**
 * @see Dao#isAutoCommit(DatabaseConnection)
 */
@Override
public boolean isAutoCommit(DatabaseConnection connection) {
  try {
    return dao.isAutoCommit(connection);
  } catch (SQLException e) {
    logMessage(e, "isAutoCommit(" + connection + ") threw exception");
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.j256.ormlite/ormlite-core

/**
 * @see Dao#isAutoCommit(DatabaseConnection)
 */
@Override
public boolean isAutoCommit(DatabaseConnection connection) {
  try {
    return dao.isAutoCommit(connection);
  } catch (SQLException e) {
    logMessage(e, "isAutoCommit(" + connection + ") threw exception");
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.j256.ormlite/ormlite-jdbc

try {
  conn1 = dao.startThreadConnection();
  assertTrue(dao.isAutoCommit(conn1));
  dao.setAutoCommit(conn1, false);
  assertFalse(dao.isAutoCommit(conn1));

代码示例来源:origin: j256/ormlite-core

@Test
public void testConnectionMethods() throws Exception {
  Dao<Foo, Integer> dao = createDao(Foo.class, true);
  DatabaseConnection conn = null;
  try {
    conn = dao.startThreadConnection();
    assertTrue(dao.isAutoCommit(conn));
    dao.setAutoCommit(conn, false);
    assertFalse(dao.isAutoCommit(conn));
    Foo foo = new Foo();
    assertEquals(1, dao.create(foo));
    assertNotNull(dao.queryForId(foo.id));
    dao.rollBack(conn);
    assertNull(dao.queryForId(foo.id));
    foo = new Foo();
    assertEquals(1, dao.create(foo));
    assertNotNull(dao.queryForId(foo.id));
    dao.commit(conn);
    assertNotNull(dao.queryForId(foo.id));
    dao.rollBack(conn);
    assertNotNull(dao.queryForId(foo.id));
  } finally {
    if (conn != null) {
      conn.setAutoCommit(true);
      dao.endThreadConnection(conn);
    }
  }
}

代码示例来源:origin: com.j256.ormlite/ormlite-jdbc

try {
  conn = dao.startThreadConnection();
  assertTrue(dao.isAutoCommit(conn));
  dao.setAutoCommit(conn, false);
  assertFalse(dao.isAutoCommit(conn));

相关文章