Package org.h2.jdbcx

Examples of org.h2.jdbcx.JdbcDataSource


  public static final String JDBC_URL = "jdbc:h2:mem:DB_CLOSE_DELAY=-1;INIT=RUNSCRIPT FROM 'classpath:schema_h2.sql'";

  @Test
  public void shouldStartRepositoryWithoutSpring() throws Exception {
    //given
    final JdbcDataSource dataSource = new JdbcDataSource();
    dataSource.setURL(JDBC_URL);

    final UserRepository userRepository = new UserRepository("users");
    userRepository.setDataSource(dataSource);
    userRepository.setSqlGenerator(new SqlGenerator())//optional
View Full Code Here


  }

  @Test
  public void shouldInsertIntoDatabase() throws Exception {
    //given
    final JdbcDataSource dataSource = new JdbcDataSource();
    dataSource.setURL(JDBC_URL);

    final UserRepository userRepository = new UserRepository("users");
    userRepository.setDataSource(dataSource);
    userRepository.setSqlGenerator(new SqlGenerator());
View Full Code Here

  private void initDB() {
    String url = servletContext.getInitParameter("db.url");
    String user = servletContext.getInitParameter("db.user");
    String pword = servletContext.getInitParameter("db.password");
    ds = new JdbcDataSource();
    ds.setURL(url);
    ds.setUser(user);
    ds.setPassword(pword);
  }
View Full Code Here

  private void loadFoodmart() throws SQLException {
    String url = servletContext.getInitParameter("foodmart.url");
    String user = servletContext.getInitParameter("foodmart.user");
    String pword = servletContext.getInitParameter("foodmart.password");
    if (url != null && !url.equals("${foodmart_url}")) {
      JdbcDataSource ds2 = new JdbcDataSource();
      ds2.setURL(url);
      ds2.setUser(user);
      ds2.setPassword(pword);

      Connection c = ds2.getConnection();
      DatabaseMetaData dbm = c.getMetaData();
      ResultSet tables = dbm.getTables(null, null, "account", null);

      if (!tables.next()) {
        // Table exists
View Full Code Here

    private DataSource _ds;

    public void setUp() throws Exception {
        super.setUp();
       
        JdbcDataSource hds = new JdbcDataSource();
        hds.setURL("jdbc:h2:mem:odeextvar;DB_CLOSE_DELAY=-1");
        hds.setUser("sa");

        _ds = hds;

        _jdbcext = new JdbcExternalVariableModule();
        _jdbcext.registerDataSource("testds", _ds);
View Full Code Here

    @Override
    protected void initDataSource() throws DatabaseConfigException {
        String db = _odeConfig.getDbEmbeddedName();
        if (_workRoot == null) {
            _dbUrl = "jdbc:h2:mem:" + db + ";DB_CLOSE_DELAY=-1";
            JdbcDataSource hds = new JdbcDataSource();
            hds.setURL(_dbUrl);
            hds.setUser("sa");
            _datasource = hds;
        } else {
            _dbUrl = "jdbc:h2:" + _workRoot + File.separator + db;
            if (!_odeConfig.isDbEmbeddedCreate()) {
                _dbUrl += ";IFEXISTS=TRUE";
View Full Code Here

    public DelegateSupport(TransactionManager txm) throws Exception {
        initialize(txm);
    }

    protected void initialize(TransactionManager txm) throws Exception {
        JdbcDataSource ds = new JdbcDataSource();
        ds.setURL("jdbc:h2:mem:" + new GUID().toString() + ";DB_CLOSE_DELAY=-1");
        ds.setUser("sa");
        ds.setPassword("");
        _ds = ds;
       
        setup();
        _del = new JdbcDelegate(_ds);
    }
View Full Code Here

        FileLocator locator = new FileLocator().with(initScriptLocation).with(mavenRelativePath).with(mavenRootRelativePath);
        File file = locator.find();
        Validate.notNull(file, locator.getErrorMessage());
        FileSystemResource script = new FileSystemResource(file);

        JdbcDataSource dataSource = new JdbcDataSource();
        dataSource.setURL("jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1");
        dataSource.setUser("sa");
        dataSource.setPassword("");

        DataSourceInitializer.initializeDataSource(dataSource, script);

        return dataSource;
    }
View Full Code Here

        atomikosConnectionFactoryBean.setIgnoreSessionTransactedFlag(false);
        registry.put("atomikos.connectionFactory", atomikosConnectionFactoryBean);


        // JDBC setup
        JdbcDataSource jdbcDataSource = EmbeddedDataSourceFactory.getJdbcDataSource("sql/schema.sql");

        AtomikosDataSourceBean atomikosDataSourceBean = new AtomikosDataSourceBean();
        atomikosDataSourceBean.setXaDataSource(jdbcDataSource);
        atomikosDataSourceBean.setUniqueResourceName("xa.h2");
        registry.put("atomikos.dataSource", atomikosDataSourceBean);
View Full Code Here

      Class.forName("org.h2.Driver");
    } catch (ClassNotFoundException e) {
      LOGGER.error(null, e);
    }

    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL(url);
    ds.setUser("sa");
    ds.setPassword("");
    cp = JdbcConnectionPool.create(ds);
  }
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.