Tabnine Logo
DatabaseConnection.isAutoCommit
Code IndexAdd Tabnine to your IDE (free)

How to use
isAutoCommit
method
in
com.j256.ormlite.support.DatabaseConnection

Best Java code snippets using com.j256.ormlite.support.DatabaseConnection.isAutoCommit (Showing top 20 results out of 315)

origin: com.j256.ormlite/ormlite-core

@Override
public boolean isAutoCommit() throws SQLException {
  if (proxy == null) {
    return false;
  } else {
    return proxy.isAutoCommit();
  }
}
origin: com.expanset.hk2/hk2-persistence-ormlite

/**
 * @param connectionSource {@link ConnectionSource} for transaction.
 * @throws SQLException Connection error.
 */
public OrmliteTransaction(@Nonnull ConnectionSource connectionSource) 
    throws SQLException {
  Validate.notNull(connectionSource, "connectionSource");
  
  this.connectionSource = connectionSource;	
  this.connection = this.connectionSource.getReadWriteConnection();
  
  final boolean saved = this.connectionSource.saveSpecialConnection(connection);	
  if (saved || connectionSource.getDatabaseType().isNestedSavePointsSupported()) {
    if (connection.isAutoCommitSupported()) {
      autoCommitAtStart = connection.isAutoCommit();
      if (autoCommitAtStart) {
        connection.setAutoCommit(false);
      }
    } else {
      autoCommitAtStart = false;
    }
    savepoint = connection.setSavePoint(SAVE_POINT_PREFIX + savepointCounter.incrementAndGet());
  } else {
    savepoint = null;
    autoCommitAtStart = false;
  }        
} 
 
origin: com.j256.ormlite/ormlite-core

try {
  if (connection.isAutoCommitSupported()) {
    if (connection.isAutoCommit()) {
origin: j256/ormlite-core

@Override
public boolean isAutoCommit() throws SQLException {
  if (proxy == null) {
    return false;
  } else {
    return proxy.isAutoCommit();
  }
}
origin: j256/ormlite-core

try {
  if (connection.isAutoCommitSupported()) {
    if (connection.isAutoCommit()) {
origin: com.j256.ormlite/ormlite-core

@Override
public boolean isAutoCommit(DatabaseConnection connection) throws SQLException {
  return connection.isAutoCommit();
}
origin: j256/ormlite-core

@Test
public void testCallBatchTasksAutoCommitFalse() throws Exception {
  TableInfo<Foo, String> tableInfo = new TableInfo<Foo, String>(databaseType, Foo.class);
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection connection = createMock(DatabaseConnection.class);
  expect(connectionSource.isSingleConnection("foo")).andReturn(false);
  expect(connectionSource.getReadWriteConnection("foo")).andReturn(connection);
  expect(connectionSource.saveSpecialConnection(connection)).andReturn(false);
  connectionSource.clearSpecialConnection(connection);
  connectionSource.releaseConnection(connection);
  expect(connection.isAutoCommitSupported()).andReturn(true);
  expect(connection.isAutoCommit()).andReturn(false);
  StatementExecutor<Foo, String> statementExec =
      new StatementExecutor<Foo, String>(databaseType, tableInfo, null);
  replay(connectionSource, connection);
  final AtomicBoolean called = new AtomicBoolean(false);
  statementExec.callBatchTasks(connectionSource, new Callable<Void>() {
    @Override
    public Void call() {
      called.set(true);
      return null;
    }
  });
  assertTrue(called.get());
  verify(connectionSource, connection);
}
origin: j256/ormlite-core

@Override
public boolean isAutoCommit(DatabaseConnection connection) throws SQLException {
  return connection.isAutoCommit();
}
origin: j256/ormlite-core

@Test
public void testTransactionManagerAutoCommitOn() throws Exception {
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  expect(conn.isAutoCommitSupported()).andReturn(true);
  expect(conn.isAutoCommit()).andReturn(true);
  conn.setAutoCommit(false);
  Savepoint savePoint = createMock(Savepoint.class);
  expect(savePoint.getSavepointName()).andReturn("name").anyTimes();
  expect(conn.setSavePoint(isA(String.class))).andReturn(savePoint);
  conn.commit(savePoint);
  conn.setAutoCommit(true);
  expect(connectionSource.getDatabaseType()).andReturn(databaseType);
  expect(connectionSource.getReadWriteConnection(null)).andReturn(conn);
  expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
  connectionSource.clearSpecialConnection(conn);
  connectionSource.releaseConnection(conn);
  replay(connectionSource, conn, savePoint);
  TransactionManager tm = new TransactionManager(connectionSource);
  tm.callInTransaction(new Callable<Void>() {
    @Override
    public Void call() {
      return null;
    }
  });
  verify(connectionSource, conn, savePoint);
}
origin: ikidou/Retrofit2Demo

Dao<Blog, Long> blogDao = DaoManager.createDao(source, Blog.class);
DatabaseConnection databaseConnection = blogDao.startThreadConnection();
boolean autoCommit = databaseConnection.isAutoCommit();
databaseConnection.setAutoCommit(false);
for (Blog blog : blogList) {
origin: j256/ormlite-core

@Test
public void testTransactionManagerAutoCommitSupported() throws Exception {
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  expect(conn.isAutoCommitSupported()).andReturn(true);
  expect(conn.isAutoCommit()).andReturn(false);
  Savepoint savePoint = createMock(Savepoint.class);
  expect(savePoint.getSavepointName()).andReturn("name").anyTimes();
  expect(conn.setSavePoint(isA(String.class))).andReturn(savePoint);
  conn.commit(savePoint);
  expect(connectionSource.getDatabaseType()).andReturn(databaseType);
  expect(connectionSource.getReadWriteConnection(null)).andReturn(conn);
  expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
  connectionSource.clearSpecialConnection(conn);
  connectionSource.releaseConnection(conn);
  replay(connectionSource, conn, savePoint);
  TransactionManager tm = new TransactionManager(connectionSource);
  tm.callInTransaction(new Callable<Void>() {
    @Override
    public Void call() {
      return null;
    }
  });
  verify(connectionSource, conn, savePoint);
}
origin: com.j256.ormlite/ormlite-core

/**
 * Return true if the two connections seem to one one connection under the covers.
 */
protected boolean isSingleConnection(DatabaseConnection conn1, DatabaseConnection conn2) throws SQLException {
  // initialize the connections auto-commit flags
  conn1.setAutoCommit(true);
  conn2.setAutoCommit(true);
  try {
    // change conn1's auto-commit to be false
    conn1.setAutoCommit(false);
    if (conn2.isAutoCommit()) {
      // if the 2nd connection's auto-commit is still true then we have multiple connections
      return false;
    } else {
      // if the 2nd connection's auto-commit is also false then we have a single connection
      return true;
    }
  } finally {
    // restore its auto-commit
    conn1.setAutoCommit(true);
  }
}
origin: j256/ormlite-core

@Test
public void testCallBatchTasksAutoCommitTrueSynchronized() throws Exception {
  TableInfo<Foo, String> tableInfo = new TableInfo<Foo, String>(databaseType, Foo.class);
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection connection = createMock(DatabaseConnection.class);
  expect(connectionSource.isSingleConnection("foo")).andReturn(true);
  expect(connectionSource.getReadWriteConnection("foo")).andReturn(connection);
  expect(connectionSource.saveSpecialConnection(connection)).andReturn(false);
  connectionSource.clearSpecialConnection(connection);
  connectionSource.releaseConnection(connection);
  expect(connection.isAutoCommitSupported()).andReturn(true);
  expect(connection.isAutoCommit()).andReturn(true);
  connection.setAutoCommit(false);
  connection.setAutoCommit(true);
  StatementExecutor<Foo, String> statementExec =
      new StatementExecutor<Foo, String>(databaseType, tableInfo, null);
  replay(connectionSource, connection);
  final AtomicBoolean called = new AtomicBoolean(false);
  statementExec.callBatchTasks(connectionSource, new Callable<Void>() {
    @Override
    public Void call() {
      called.set(true);
      return null;
    }
  });
  assertTrue(called.get());
  verify(connectionSource, connection);
}
origin: j256/ormlite-core

/**
 * Return true if the two connections seem to one one connection under the covers.
 */
protected boolean isSingleConnection(DatabaseConnection conn1, DatabaseConnection conn2) throws SQLException {
  // initialize the connections auto-commit flags
  conn1.setAutoCommit(true);
  conn2.setAutoCommit(true);
  try {
    // change conn1's auto-commit to be false
    conn1.setAutoCommit(false);
    if (conn2.isAutoCommit()) {
      // if the 2nd connection's auto-commit is still true then we have multiple connections
      return false;
    } else {
      // if the 2nd connection's auto-commit is also false then we have a single connection
      return true;
    }
  } finally {
    // restore its auto-commit
    conn1.setAutoCommit(true);
  }
}
origin: j256/ormlite-core

@Test
public void testCallBatchTasksAutoCommitTrue() throws Exception {
  TableInfo<Foo, String> tableInfo = new TableInfo<Foo, String>(databaseType, Foo.class);
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection connection = createMock(DatabaseConnection.class);
  expect(connectionSource.isSingleConnection("foo")).andReturn(false);
  expect(connectionSource.getReadWriteConnection("foo")).andReturn(connection);
  expect(connectionSource.saveSpecialConnection(connection)).andReturn(false);
  connectionSource.clearSpecialConnection(connection);
  connectionSource.releaseConnection(connection);
  expect(connection.isAutoCommitSupported()).andReturn(true);
  expect(connection.isAutoCommit()).andReturn(true);
  connection.setAutoCommit(false);
  connection.setAutoCommit(true);
  StatementExecutor<Foo, String> statementExec =
      new StatementExecutor<Foo, String>(databaseType, tableInfo, null);
  replay(connectionSource, connection);
  final AtomicBoolean called = new AtomicBoolean(false);
  statementExec.callBatchTasks(connectionSource, new Callable<Void>() {
    @Override
    public Void call() {
      called.set(true);
      return null;
    }
  });
  assertTrue(called.get());
  verify(connectionSource, connection);
}
origin: j256/ormlite-core

@Test
public void testIsAutoCommit() throws Exception {
  DatabaseConnection conn = createMock(DatabaseConnection.class);
  boolean autoCommit = false;
  expect(conn.isAutoCommit()).andReturn(autoCommit);
  conn.close();
  DatabaseConnectionProxy proxy = new DatabaseConnectionProxy(conn);
  replay(conn);
  assertEquals(autoCommit, proxy.isAutoCommit());
  proxy.close();
  verify(conn);
}
origin: j256/ormlite-core

@Test
public void testCallBatchTasksAutoCommitTrueThrow() throws Exception {
  TableInfo<Foo, String> tableInfo = new TableInfo<Foo, String>(databaseType, Foo.class);
  ConnectionSource connectionSource = createMock(ConnectionSource.class);
  DatabaseConnection connection = createMock(DatabaseConnection.class);
  expect(connectionSource.isSingleConnection("foo")).andReturn(false);
  expect(connectionSource.getReadWriteConnection("foo")).andReturn(connection);
  expect(connectionSource.saveSpecialConnection(connection)).andReturn(false);
  connectionSource.clearSpecialConnection(connection);
  connectionSource.releaseConnection(connection);
  expect(connection.isAutoCommitSupported()).andReturn(true);
  expect(connection.isAutoCommit()).andReturn(true);
  connection.setAutoCommit(false);
  connection.setAutoCommit(true);
  StatementExecutor<Foo, String> statementExec =
      new StatementExecutor<Foo, String>(databaseType, tableInfo, null);
  replay(connectionSource, connection);
  try {
    statementExec.callBatchTasks(connectionSource, new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        throw new Exception("expected");
      }
    });
    fail("Should have thrown");
  } catch (Exception e) {
    // expected
  }
  verify(connectionSource, connection);
}
origin: com.j256.ormlite/ormlite-jdbc

@Test
public void testSetAutoCommit() throws Exception {
  JdbcPooledConnectionSource pooled = new JdbcPooledConnectionSource(DEFAULT_DATABASE_URL);
  try {
    DatabaseConnection conn1 = pooled.getReadOnlyConnection(null);
    conn1.setAutoCommit(false);
    pooled.releaseConnection(conn1);
    DatabaseConnection conn2 = pooled.getReadOnlyConnection(null);
    assertSame(conn1, conn2);
    assertTrue(conn2.isAutoCommit());
  } finally {
    pooled.close();
  }
}
origin: j256/ormlite-core

if (saved || databaseType.isNestedSavePointsSupported()) {
  if (connection.isAutoCommitSupported()) {
    if (connection.isAutoCommit()) {
origin: com.j256.ormlite/ormlite-core

if (saved || databaseType.isNestedSavePointsSupported()) {
  if (connection.isAutoCommitSupported()) {
    if (connection.isAutoCommit()) {
com.j256.ormlite.supportDatabaseConnectionisAutoCommit

Javadoc

Return if auto-commit is currently enabled.

Popular methods of DatabaseConnection

  • executeStatement
    Execute a statement directly on the connection.
  • setAutoCommit
    Set the auto-commit to be on (true) or off (false). Setting auto-commit to true may or may-not cause
  • commit
    Commit all changes since the savepoint was created. If savePoint is null then commit all outstanding
  • compileStatement
    Like compileStatement(String, StatementType, FieldType[]) except the caller can specify the result f
  • setSavePoint
    Start a save point with a certain name. It can be a noop if savepoints are not supported.
  • close
  • closeQuietly
    Close the connection to the database but swallow any exceptions.
  • insert
    Perform a SQL update while with the associated SQL statement, arguments, and types. This will possib
  • isAutoCommitSupported
    Return if auto-commit is supported.
  • queryForLong
    Perform a query whose result should be a single long-integer value.
  • rollback
    Roll back all changes since the savepoint was created. If savePoint is null then roll back all outst
  • delete
    Perform a SQL delete with the associated SQL statement, arguments, and types.
  • rollback,
  • delete,
  • isClosed,
  • isTableExists,
  • queryForOne,
  • update,
  • releaseSavePoint

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • getSupportFragmentManager (FragmentActivity)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now