Examples of JdbcConnectionSource


Examples of com.j256.ormlite.jdbc.JdbcConnectionSource

    TestUtils.deleteDirectory(dbDir);
    dbDir.mkdirs();
    assertEquals(0, dbDir.list().length);
    closeConnectionSource();
    String dbUrl = "jdbc:h2:" + dbDir.getPath() + "/" + DATABASE_NAME;
    connectionSource = new JdbcConnectionSource(dbUrl);
    DatabaseConnection conn = connectionSource.getReadWriteConnection();
    try {
      databaseType = DatabaseTypeUtils.createDatabaseType(dbUrl);
      assertTrue(dbDir.list().length != 0);
    } finally {
View Full Code Here

Examples of com.j256.ormlite.jdbc.JdbcConnectionSource

  private final static String GENERATED_ID_SEQ = "genId_seq";

  @Override
  protected void setDatabaseParams() throws SQLException {
    databaseUrl = "jdbc:hsqldb:ormlite";
    connectionSource = new JdbcConnectionSource(DEFAULT_DATABASE_URL);
    databaseType = new HsqldbDatabaseType();
  }
View Full Code Here

Examples of com.j256.ormlite.jdbc.JdbcConnectionSource

    int notTheRightPort = 12345;
    closeConnectionSource();
    // try to disable the retry feature which delays this test failure
    System.setProperty("h2.socketConnectRetry", "0");
    String dbUrl = "jdbc:h2:tcp://localhost:" + notTheRightPort + "/" + dbDir.getPath() + "/" + DATABASE_NAME;
    connectionSource = new JdbcConnectionSource(dbUrl);
    DatabaseConnection conn = connectionSource.getReadOnlyConnection();
    try {
      DatabaseTypeUtils.createDatabaseType(dbUrl);
    } finally {
      connectionSource.releaseConnection(conn);
View Full Code Here

Examples of com.j256.ormlite.jdbc.JdbcConnectionSource

public class SqlServerJtdsDatabaseConnectTypeTest extends SqlServerDatabaseTypeTest {

  @Override
  protected void setDatabaseParams() throws SQLException {
    databaseUrl = "jdbc:jtds:sqlserver://db/ormlite;ssl=request";
    connectionSource = new JdbcConnectionSource(DEFAULT_DATABASE_URL);
    databaseType = new SqlServerJtdsDatabaseType();
  }
View Full Code Here

Examples of com.j256.ormlite.jdbc.JdbcConnectionSource

    // turn our static method into an instance of Main
    new ManyToManyMain().doMain(args);
  }

  private void doMain(String[] args) throws Exception {
    JdbcConnectionSource connectionSource = null;
    try {
      // create our data-source for the database
      connectionSource = new JdbcConnectionSource(DATABASE_URL);
      // setup our database and DAOs
      setupDatabase(connectionSource);
      // read and write some data
      readWriteData();
      System.out.println("\n\nIt seems to have worked\n\n");
    } finally {
      // destroy the data source which should close underlying connections
      if (connectionSource != null) {
        connectionSource.close();
      }
    }
  }
View Full Code Here

Examples of com.j256.ormlite.jdbc.JdbcConnectionSource

  @Override
  protected void setDatabaseParams() throws SQLException {
    System.setProperty("derby.stream.error.file", "target/derby.log");
    databaseUrl = "jdbc:derby:target/ormlitederby;create=true";
    connectionSource = new JdbcConnectionSource(DEFAULT_DATABASE_URL);
    databaseType = new DerbyEmbeddedDatabaseType();
  }
View Full Code Here

Examples of com.j256.ormlite.jdbc.JdbcConnectionSource

public class OracleDatabaseTypeTest extends BaseJdbcDatabaseTypeTest {

  @Override
  protected void setDatabaseParams() throws SQLException {
    databaseUrl = "jdbc:oracle:ormliteoracle";
    connectionSource = new JdbcConnectionSource(DEFAULT_DATABASE_URL);
    databaseType = new OracleDatabaseType();
  }
View Full Code Here

Examples of com.j256.ormlite.jdbc.JdbcConnectionSource

  private void doOpenConnectionSource() throws Exception {
    if (connectionSource == null) {
      isConnectionExpected = isConnectionExpected();
      if (isConnectionExpected) {
        connectionSource = new JdbcConnectionSource(databaseUrl, userName, password);
      }
    }
    if (databaseType == null) {
      if (connectionSource != null) {
        databaseType = connectionSource.getDatabaseType();
View Full Code Here

Examples of com.j256.ormlite.jdbc.JdbcConnectionSource

  @Test
  public void testDoubleDbOpen() throws Exception {
    clearDatabases();
    ConnectionSource cs =
        new JdbcConnectionSource("jdbc:h2:file:" + DATABASE_DIR + "/" + DATABASE_NAME_PREFIX + ".1");
    TableUtils.createTable(cs, Foo.class);
    Dao<Foo, Integer> dao = DaoManager.createDao(cs, Foo.class);
    Foo foo1 = new Foo();
    foo1.val = 12312;
    assertEquals(1, dao.create(foo1));

    Foo result = dao.queryForId(foo1.id);
    assertNotNull(result);
    assertEquals(foo1.val, result.val);

    // ==================================

    cs = new JdbcConnectionSource("jdbc:h2:file:" + DATABASE_DIR + "/" + DATABASE_NAME_PREFIX + ".2");
    DaoManager.clearCache();
    TableUtils.createTable(cs, Foo.class);
    dao = DaoManager.createDao(cs, Foo.class);
    Foo foo2 = new Foo();
    foo2.val = 12314;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.