Package com.j256.ormlite.jdbc

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


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

    // 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

  @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

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

  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

  @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

   * <b>NOTE:</b> I couldn't remove the code warning associated with this method when used with more than 2 arguments.
   * </p>
   */
  public Where<T, ID> and(Where<T, ID> first, Where<T, ID> second, Where<T, ID>... others) {
    Clause[] clauses = buildClauseArray(others, "AND");
    Clause secondClause = pop("AND");
    Clause firstClause = pop("AND");
    addClause(new ManyClause(firstClause, secondClause, clauses, ManyClause.AND_OPERATION));
    return this;
  }
View Full Code Here

   * <b>NOTE:</b> I can't remove the code warning associated with this method. Use the iterator method below.
   * </p>
   */
  public Where<T, ID> or(Where<T, ID> left, Where<T, ID> right, Where<T, ID>... others) {
    Clause[] clauses = buildClauseArray(others, "OR");
    Clause secondClause = pop("OR");
    Clause firstClause = pop("OR");
    addClause(new ManyClause(firstClause, secondClause, clauses, ManyClause.OR_OPERATION));
    return this;
  }
View Full Code Here

  @Override
  public String toString() {
    if (clauseStackLevel == 0) {
      return "empty where clause";
    } else {
      Clause clause = peek();
      return "where clause: " + clause;
    }
  }
View Full Code Here

TOP

Related Classes of com.j256.ormlite.jdbc.JdbcConnectionSource

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.