Package org.h2.jdbcx

Examples of org.h2.jdbcx.JdbcConnectionPool


    private QueryRunner qr;

    public QueryRunnerProvider(ServletContext servletContext) throws Exception {
        Class.forName("org.h2.Driver");

        JdbcConnectionPool pool = JdbcConnectionPool.create("jdbc:h2:" + servletContext.getRealPath("/WEB-INF/h2") + ";LOCK_MODE=0", "sa", "");

        qr = new QueryRunner(pool);

        Object obj = qr.query("show tables", new ScalarHandler<Object>());
        if (obj == null) {
View Full Code Here


    public QueryRunner get() {
        return qr;
    }

    public void dispose() {
        JdbcConnectionPool pool = (JdbcConnectionPool) qr.getDataSource();
        pool.dispose();
    }
View Full Code Here

    @Inject
    private TextEncryptor textEncryptor;

    @Bean(destroyMethod="dispose")
    public DataSource dataSource() {
      JdbcConnectionPool dataSource = JdbcConnectionPool.create(environment.getProperty("database.url"),
          environment.getProperty("database.username"), environment.getProperty("database.password"));
      new DatabaseUpgrader(dataSource, environment, textEncryptor).run();
      return dataSource;
    }
View Full Code Here

    protected AbstractBlobStore store;
    private Connection sentinel;

    public void setUp() throws Exception {
        Class.forName("org.h2.Driver");
        JdbcConnectionPool cp = JdbcConnectionPool.create("jdbc:h2:mem:", "", "");
        sentinel = cp.getConnection();
        DbBlobStore blobStore = new DbBlobStore();
        blobStore.setConnectionPool(cp);
        blobStore.setBlockSize(128);
        blobStore.setBlockSizeMin(32);
        this.store = blobStore;
View Full Code Here

        String extraParms=";LOCK_MODE=0;DB_CLOSE_ON_EXIT=TRUE;FILE_LOCK=NO";
        File dbRoot=new File(ConfigUtils.getDynamicContentPath() + File.separator + "h2db/" + x + "/cache_db" + x + extraParms);
 
        String dbRootLocation=dbRoot.getAbsolutePath();
        String connectURI="jdbc:h2:split:nio:"+dbRootLocation;
        JdbcConnectionPool cp = JdbcConnectionPool.create(connectURI, "sa", "sa");
        cp.setMaxConnections(1000);
        cp.setLoginTimeout(3);
        addConPoolToPoolMap(x, cp);
        //make sure we can connect
        conn = createConnection(true,x);
      }catch (Exception e) {
        Logger.fatal(this, "Unable to start db properly : " + e.getMessage(),e);
View Full Code Here

        testReadOnly();
        testAdapter();
    }

    private static void testAdapter() {
        TraceSystem ts = new TraceSystem(null);
        ts.setLevelFile(TraceSystem.ADAPTER);
        ts.getTrace("test").info("test");
        ts.close();
    }
View Full Code Here

        ts.getTrace("test").info("test");
        ts.close();
    }

    private void testTraceDebug() {
        TraceSystem ts = new TraceSystem(null);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ts.setSysOut(new PrintStream(out));
        ts.setLevelSystemOut(TraceSystem.DEBUG);
        ts.getTrace("test").debug(new Exception("error"), "test");
        ts.close();
        String outString = new String(out.toByteArray());
        assertContains(outString, "error");
        assertContains(outString, "Exception");
        assertContains(outString, "test");
    }
View Full Code Here

    private void testReadOnly() throws Exception {
        String readOnlyFile = getBaseDir() + "/readOnly.log";
        IOUtils.delete(readOnlyFile);
        IOUtils.openFileOutputStream(readOnlyFile, false).close();
        FileSystem.getInstance(getBaseDir()).setReadOnly(readOnlyFile);
        TraceSystem ts = new TraceSystem(readOnlyFile);
        ts.setLevelFile(TraceSystem.INFO);
        ts.getTrace("test").info("test");
        IOUtils.delete(readOnlyFile);
        ts.close();
    }
View Full Code Here

        FileSystem.getInstance("split:").delete("split:" + getBaseDir() + "/openClose2.h2.db");
        Connection conn;
        conn = DriverManager.getConnection("jdbc:h2:split:18:" + getBaseDir() + "/openClose2");
        conn.createStatement().execute("create table test(id int, name varchar) as select 1, space(1000000)");
        conn.close();
        FileObject f = FileSystem.getInstance(getBaseDir()).openFileObject(getBaseDir() + "/openClose2.h2.db.1.part", "rw");
        f.setFileLength(f.length() * 2);
        f.close();
        assertThrows(ErrorCode.IO_EXCEPTION_2, this).
                getConnection("jdbc:h2:split:18:" + getBaseDir() + "/openClose2");
        FileSystem.getInstance("split:").delete("split:" + getBaseDir() + "/openClose2.h2.db");
    }
View Full Code Here

        // mvcc & row level locking
        new TestMvcc1().runTest(this);
        new TestMvcc2().runTest(this);
        new TestMvcc3().runTest(this);
        new TestMvccMultiThreaded().runTest(this);
        new TestRowLocks().runTest(this);

        // synth
        new TestBtreeIndex().runTest(this);
        new TestCrashAPI().runTest(this);
        new TestFuzzOptimizations().runTest(this);
View Full Code Here

TOP

Related Classes of org.h2.jdbcx.JdbcConnectionPool

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.