Package com.j256.ormlite.support

Examples of com.j256.ormlite.support.DatabaseConnection


  public WrappedConnectionSource(ConnectionSource cs) throws SQLException {
    this.cs = cs;
  }

  public DatabaseConnection getReadOnlyConnection() throws SQLException {
    DatabaseConnection connection = cs.getReadOnlyConnection();
    getReleaseCount.incrementAndGet();
    WrappedConnection wrapped = wrapConnection(connection);
    wrappedConnections.put(wrapped.getDatabaseConnectionProxy(), wrapped);
    // System.err.println("got wrapped " + wrapped.hashCode() + ", count = " + getReleaseCount);
    // new RuntimeException().printStackTrace();
View Full Code Here


    // new RuntimeException().printStackTrace();
    return wrapped.getDatabaseConnectionProxy();
  }

  public DatabaseConnection getReadWriteConnection() throws SQLException {
    DatabaseConnection connection = cs.getReadWriteConnection();
    getReleaseCount.incrementAndGet();
    WrappedConnection wrapped = wrapConnection(connection);
    connection = wrapped.getDatabaseConnectionProxy();
    wrappedConnections.put(connection, wrapped);
    // System.err.println("got wrapped " + wrapped.hashCode() + ", count = " + getReleaseCount);
View Full Code Here

public class TransactionManagerTest extends BaseCoreTest {

  @Test
  public void testTransactionManager() throws Exception {
    ConnectionSource connectionSource = createMock(ConnectionSource.class);
    DatabaseConnection conn = createMock(DatabaseConnection.class);
    expect(conn.isAutoCommitSupported()).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()).andReturn(conn);
    expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
    connectionSource.clearSpecialConnection(conn);
    connectionSource.releaseConnection(conn);
View Full Code Here

  }

  @Test
  public void testTransactionManagerSavePointNull() throws Exception {
    ConnectionSource connectionSource = createMock(ConnectionSource.class);
    DatabaseConnection conn = createMock(DatabaseConnection.class);
    expect(conn.isAutoCommitSupported()).andReturn(false);
    expect(conn.setSavePoint(isA(String.class))).andReturn(null);
    conn.commit(null);
    expect(connectionSource.getDatabaseType()).andReturn(databaseType);
    expect(connectionSource.getReadWriteConnection()).andReturn(conn);
    expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
    connectionSource.clearSpecialConnection(conn);
    connectionSource.releaseConnection(conn);
View Full Code Here

  }

  @Test
  public void testTransactionManagerRollback() throws Exception {
    ConnectionSource connectionSource = createMock(ConnectionSource.class);
    DatabaseConnection conn = createMock(DatabaseConnection.class);
    expect(conn.isAutoCommitSupported()).andReturn(false);
    Savepoint savePoint = createMock(Savepoint.class);
    expect(savePoint.getSavepointName()).andReturn("name").anyTimes();
    expect(conn.setSavePoint(isA(String.class))).andReturn(savePoint);
    conn.rollback(savePoint);
    expect(connectionSource.getDatabaseType()).andReturn(databaseType);
    expect(connectionSource.getReadWriteConnection()).andReturn(conn);
    expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
    connectionSource.clearSpecialConnection(conn);
    connectionSource.releaseConnection(conn);
View Full Code Here

  }

  @Test
  public void testTransactionManagerRollbackNullSavePoint() throws Exception {
    ConnectionSource connectionSource = createMock(ConnectionSource.class);
    DatabaseConnection conn = createMock(DatabaseConnection.class);
    expect(conn.isAutoCommitSupported()).andReturn(false);
    expect(conn.setSavePoint(isA(String.class))).andReturn(null);
    conn.rollback(null);
    expect(connectionSource.getDatabaseType()).andReturn(databaseType);
    expect(connectionSource.getReadWriteConnection()).andReturn(conn);
    expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
    connectionSource.clearSpecialConnection(conn);
    connectionSource.releaseConnection(conn);
View Full Code Here

  }

  @Test
  public void testTransactionManagerRollbackOtherException() throws Exception {
    ConnectionSource connectionSource = createMock(ConnectionSource.class);
    DatabaseConnection conn = createMock(DatabaseConnection.class);
    expect(conn.isAutoCommitSupported()).andReturn(false);
    Savepoint savePoint = createMock(Savepoint.class);
    expect(savePoint.getSavepointName()).andReturn("name").anyTimes();
    expect(conn.setSavePoint(isA(String.class))).andReturn(savePoint);
    conn.rollback(savePoint);
    expect(connectionSource.getDatabaseType()).andReturn(databaseType);
    expect(connectionSource.getReadWriteConnection()).andReturn(conn);
    expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
    connectionSource.clearSpecialConnection(conn);
    connectionSource.releaseConnection(conn);
View Full Code Here

  }

  @Test
  public void testTransactionManagerAutoCommitSupported() throws Exception {
    ConnectionSource connectionSource = createMock(ConnectionSource.class);
    DatabaseConnection conn = createMock(DatabaseConnection.class);
    expect(conn.isAutoCommitSupported()).andReturn(true);
    expect(conn.getAutoCommit()).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()).andReturn(conn);
    expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
    connectionSource.clearSpecialConnection(conn);
    connectionSource.releaseConnection(conn);
View Full Code Here

  }

  @Test
  public void testTransactionManagerAutoCommitOn() throws Exception {
    ConnectionSource connectionSource = createMock(ConnectionSource.class);
    DatabaseConnection conn = createMock(DatabaseConnection.class);
    expect(conn.isAutoCommitSupported()).andReturn(true);
    expect(conn.getAutoCommit()).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()).andReturn(conn);
    expect(connectionSource.saveSpecialConnection(conn)).andReturn(true);
    connectionSource.clearSpecialConnection(conn);
    connectionSource.releaseConnection(conn);
View Full Code Here

  @Test
  public void testIndex() throws Exception {
    final ConnectionSource connectionSource = createMock(ConnectionSource.class);
    expect(connectionSource.getDatabaseType()).andReturn(databaseType).anyTimes();
    DatabaseConnection conn = createMock(DatabaseConnection.class);
    expect(connectionSource.getReadWriteConnection()).andReturn(conn);
    final CompiledStatement stmt = createMock(CompiledStatement.class);
    expect(conn.compileStatement(isA(String.class), isA(StatementType.class), isA(FieldType[].class))).andAnswer(
        new IAnswer<CompiledStatement>() {
          private int stmtC = 0;
          public CompiledStatement answer() throws Throwable {
            Object[] args = EasyMock.getCurrentArguments();
            assertNotNull(args);
View Full Code Here

TOP

Related Classes of com.j256.ormlite.support.DatabaseConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.