Package org.h2.jdbcx

Examples of org.h2.jdbcx.JdbcDataSource


  @Override
  protected void setUp() throws Exception {

    // Setup in-memory H2 JDBC DataSource;
    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL("jdbc:h2:mem:testdb");
    ds.setUser("sa");
    ds.setPassword("sa");
    dataSource = ds;
    database = new JdbcDatabase(dataSource);
  }
View Full Code Here


    verify(ds, alive, deadAfterSomeTime);
  }

  public void testConnectionPoolwithH2() throws SQLException {
    // Setup in-memory H2 JDBC DataSource;
    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL("jdbc:h2:mem:testdb");
    ds.setUser("sa");
    ds.setPassword("sa");
   
    DatabaseConnectionPool pool = new DatabaseConnectionPool(ds);
    //Test getConnection
    Connection c = pool.getConnection();
    assertTrue(c.isValid(1));
View Full Code Here

  @Override
  protected void setUp() throws Exception {
    super.setUp();

    // Setup in-memory H2 JDBC DataSource;
    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL("jdbc:h2:mem:testdb");
    ds.setUser("sa");
    ds.setPassword("sa");
    dataSource = ds;
    jdbcDatabase = new JdbcDatabase(ds);

    store = new JdbcStore();
    ((JdbcStore) store).setDatabase(jdbcDatabase);
View Full Code Here

    DataSource ds = JdbcDataSourceFactory.newJdbcDataSource("In-memory H2",
        "org.h2.jdbcx.JdbcDataSource", "jdbc:h2:mem:testdb");
    assertNotNull(ds);
    assertTrue(ds instanceof org.h2.jdbcx.JdbcDataSource);

    JdbcDataSource h2ds = (JdbcDataSource) ds;
    h2ds.setURL("jdbc:h2:mem:testdb");
    h2ds.setUser("sa");
    h2ds.setPassword("");
    h2ds.getConnection().close();
  }
View Full Code Here

    }

    @Override
    protected Connection createConnection() throws SQLException
    {
        final JdbcDataSource ds = new org.h2.jdbcx.JdbcDataSource();
        ds.setURL("jdbc:h2:" + dbFileName.getAbsolutePath() + ";DB_CLOSE_ON_EXIT=FALSE");
        ds.setUser("sa");
        Connection results = ds.getConnection();
        results.setAutoCommit(false);
        return results;
    }
View Full Code Here

        persistenceUnitProperties.put("javax.persistence.jdbc.url", url);
        // OpenJPA
        persistenceUnitProperties.put("openjpa.Connection2URL", url);
        // Hibernate
        persistenceUnitProperties.put("hibernate.connection.url", url);
        JdbcDataSource dataSource = new JdbcDataSource();
        dataSource.setURL(url);
        String dataSourceUrl = "java:/dummyDataSource_" + s;
        try {
            new InitialContext().bind(dataSourceUrl, dataSource);
        } catch (NamingException e) {
            throw new AssertionError(e);
View Full Code Here

    verify(ds, c, statement, rs);
  }

  public void testConstructorWithH2() throws SQLException {
    // Setup in-memory H2 JDBC DataSource;
    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL("jdbc:h2:mem:");
    ds.setUser("sa");
    ds.setPassword("");
    AdDbUtil util = new AdDbUtil(ds, "H2");
    util.select(AdDbUtil.Query.TEST_CONNECTORNAME, null);
    util.select(AdDbUtil.Query.TEST_SERVERS, null);
    util.select(AdDbUtil.Query.TEST_MEMBERS, null);
    util.select(AdDbUtil.Query.TEST_ENTITIES, null);
View Full Code Here

  /**
   * Tests that a 64-bit value greater than 2^31 - 1 can be written to
   * and read from the database.
   */
  public void testHighestCommittedUsn() throws SQLException {
    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL("jdbc:h2:mem:");
    ds.setUser("sa");
    ds.setPassword("");
    AdDbUtil util = new AdDbUtil(ds, "H2");

    Map<String, Object> queryParams =
        ImmutableMap.<String, Object>of(AdConstants.DB_DN, "DC=example,DC=com");

View Full Code Here

    private final Connection jdbcConnection;

    public static Connection getConnection() {
      try {
        JdbcDataSource ds = new JdbcDataSource();
        ds.setURL("jdbc:h2:mem:test");
        ds.setUser("sa");
        ds.setPassword("");
        return ds.getConnection();
      } catch (SQLException e) {
        throw new RuntimeException(e);
      }
    }
View Full Code Here

  private JdbcDataSource dataSource;
  private Connection connection;
 
  @Before
  public void plumb() throws Exception {
    dataSource = new JdbcDataSource();
    dataSource.setURL("jdbc:h2:mem:" + System.nanoTime());
    connection = dataSource.getConnection();
    connection.prepareStatement(PersistentIDGenerator.loadSQLResource("create")).execute();
  }
View Full Code Here

TOP

Related Classes of org.h2.jdbcx.JdbcDataSource

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.