当前位置: 首页>>代码示例>>Java>>正文


Java JdbcConnectionPool类代码示例

本文整理汇总了Java中org.h2.jdbcx.JdbcConnectionPool的典型用法代码示例。如果您正苦于以下问题:Java JdbcConnectionPool类的具体用法?Java JdbcConnectionPool怎么用?Java JdbcConnectionPool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JdbcConnectionPool类属于org.h2.jdbcx包,在下文中一共展示了JdbcConnectionPool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  registry = RegistryService.getMetricRegistry();

  String sqlId = new StringUniqueIdService().getUniqueId(SELECT_QUERY);
  executeStatementName = JdbcRuleHelper.EXECUTE_STATEMENT_NAME.withTags("sql", sqlId);

  presetElements = IntStream.range(0, 1000).boxed()
      .collect(Collectors.toMap(i -> UUID.randomUUID().toString(), i -> i));
  presetElementKeys = new ArrayList<>(presetElements.keySet());

  StringBuilder sb = new StringBuilder(CREATE_TABLE_STRING);
  presetElements.forEach((s, o) -> {
    sb.append("\nINSERT INTO TEST VALUES('").append(s).append("', ").append(o).append(");");
  });

  String dbName = "JDBCInstrumentationTest." + UUID.randomUUID();
  datasource = JdbcConnectionPool.create("jdbc:h2:mem:" + dbName, "h2", "h2");
  ((JdbcConnectionPool) datasource).setMaxConnections(POOL_SIZE);
  datasource.setLoginTimeout(-1);
  Connection conn = datasource.getConnection();
  RunScript.execute(conn, new StringReader(sb.toString()));
  conn.close();
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:25,代码来源:JDBCInstrumentationTest.java

示例2: initialize

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
@Override
public Addon initialize(ServiceConfig serviceConfig) {
    String databaseName = unitTest ? "" : ! isNullOrEmpty(name) ? name : "test";

    DataSource dataSource = JdbcConnectionPool.create("jdbc:h2:mem:" + databaseName + ";DB_CLOSE_DELAY=-1", "user", "password");
    scripts.forEach(script -> {

        try {
            Connection conn = dataSource.getConnection();
            conn.createStatement().executeUpdate(script);
            conn.close();
        } catch (SQLException ex) {
            throw new RuntimeException(ex);
        }
    });

    return this.withDataSource(dataSource);
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:19,代码来源:H2InMemoryDatasourceAddon.java

示例3: testPerformance

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
private void testPerformance() throws SQLException {
    String url = getURL("connectionPool", true), user = getUser();
    String password = getPassword();
    JdbcConnectionPool man = JdbcConnectionPool.create(url, user, password);
    Connection conn = man.getConnection();
    int len = 1000;
    long time = System.currentTimeMillis();
    for (int i = 0; i < len; i++) {
        man.getConnection().close();
    }
    man.dispose();
    trace((int) (System.currentTimeMillis() - time));
    time = System.currentTimeMillis();
    for (int i = 0; i < len; i++) {
        DriverManager.getConnection(url, user, password).close();
    }
    trace((int) (System.currentTimeMillis() - time));
    conn.close();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:20,代码来源:TestConnectionPool.java

示例4: init

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
@Override
public void init(DbConnection connection) throws Exception {
    JdbcConnectionPool pool = JdbcConnectionPool.create(connection.uri, connection.username, connection.password);

    TransactionFactory transactionFactory = new JdbcTransactionFactory();
    Environment environment = new Environment("jdblender", transactionFactory, pool);

    Configuration cfg = new Configuration(environment);
    cfg.setMapUnderscoreToCamelCase(true);
    cfg.addMapper(BrandsMapper.class);
    cfg.addMapper(SeriesMapper.class);
    cfg.addMapper(ModelsMapper.class);
    cfg.addMapper(SparesMapper.class);

    //Create session
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(cfg);
}
 
开发者ID:rumatoest,项目名称:jdblender,代码行数:18,代码来源:RunnerMybatis.java

示例5: init

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
@Override
public void init() throws Exception {
    File dir = new File(this.dbPath);
    if (dir.exists()) {
        FileUtils.cleanDirectory(dir);
    }
    this.connPool = JdbcConnectionPool.create("jdbc:h2:" + this.dbPath + SYS_CONFIG.getExecId(), "sa", "sa");
    connPool.setMaxConnections(Integer.MAX_VALUE);
    try (Connection conn = this.getConnection()) {
        try {
            conn.prepareStatement("SELECT * FROM case_result WHERE 0;").executeQuery();
        } catch (SQLException ex) {
            LOG.warn("{}", ex.getMessage());
            this.initSchema();
        }
    }
}
 
开发者ID:tascape,项目名称:reactor,代码行数:18,代码来源:H2Handler.java

示例6: DLNAMediaDatabase

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
public DLNAMediaDatabase(String name) {
	dbName = name;
	File profileFolder = new File(configuration.getProfileFolder());
	dbDir = new File(profileFolder.isDirectory() ? profileFolder : null, "database").getAbsolutePath();
	boolean logDB = configuration.getDatabaseLogging();
	url = Constants.START_URL + dbDir + File.separator + dbName + (logDB ? ";TRACE_LEVEL_FILE=4" : "");
	LOGGER.debug("Using database URL: {}", url);
	LOGGER.info("Using database located at: \"{}\"", dbDir);
	if (logDB) {
		LOGGER.info("Database logging is enabled");
	} else if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("Database logging is disabled");
	}

	try {
		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);
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:27,代码来源:DLNAMediaDatabase.java

示例7: PipelineMavenPluginH2Dao

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
public PipelineMavenPluginH2Dao(File rootDir) {
    rootDir.getClass(); // check non null

    File databaseFile = new File(rootDir, "jenkins-jobs");
    String jdbcUrl = "jdbc:h2:file:" + databaseFile.getAbsolutePath() + ";AUTO_SERVER=TRUE;MULTI_THREADED=1";
    if(LOGGER.isLoggable(Level.FINEST)) {
        jdbcUrl += ";TRACE_LEVEL_SYSTEM_OUT=3";
    } else if (LOGGER.isLoggable(Level.FINE)) {
        jdbcUrl += ";TRACE_LEVEL_SYSTEM_OUT=2";
    }
    LOGGER.log(Level.INFO, "Open database {0}", jdbcUrl);
    jdbcConnectionPool = JdbcConnectionPool.create(jdbcUrl, "sa", "sa");

    initializeDatabase();
    testDatabase();
}
 
开发者ID:jenkinsci,项目名称:pipeline-maven-plugin,代码行数:17,代码来源:PipelineMavenPluginH2Dao.java

示例8: init

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
static void init() {
    long maxCacheSize = Nhz.getIntProperty("nhz.dbCacheKB");
    if (maxCacheSize == 0) {
        maxCacheSize = Runtime.getRuntime().maxMemory() / (1024 * 2);
    }
    String dbUrl = Constants.isTestnet ? Nhz.getStringProperty("nhz.testDbUrl") : Nhz.getStringProperty("nhz.dbUrl");
    if (! dbUrl.contains("CACHE_SIZE=")) {
        dbUrl += ";CACHE_SIZE=" + maxCacheSize;
    }
    Logger.logDebugMessage("Database jdbc url set to: " + dbUrl);
    cp = JdbcConnectionPool.create(dbUrl, "sa", "sa");
    cp.setMaxConnections(Nhz.getIntProperty("nhz.maxDbConnections"));
    cp.setLoginTimeout(Nhz.getIntProperty("nhz.dbLoginTimeout"));
    int defaultLockTimeout = Nhz.getIntProperty("nhz.dbDefaultLockTimeout") * 1000;
    try (Connection con = cp.getConnection();
         Statement stmt = con.createStatement()) {
        stmt.executeUpdate("SET DEFAULT_LOCK_TIMEOUT " + defaultLockTimeout);
    } catch (SQLException e) {
        throw new RuntimeException(e.toString(), e);
    }
    DbVersion.init();
}
 
开发者ID:atcsecure,项目名称:horizon-blocknet,代码行数:23,代码来源:Db.java

示例9: initialize

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
@BeforeClass
public static void initialize() throws ClassNotFoundException, SQLException {
    pool = JdbcConnectionPool.create("jdbc:h2:mem:test", "sa", "");

    Connection connection = getConnection();
    try {
        Statement statement = connection.createStatement();
        statement.execute("CREATE TABLE users (" +
                "userId INT PRIMARY KEY, " +
                "name VARCHAR(255), " +
                "birthyear INT, " +
                "employeeType VARCHAR(16)) " +
                "AS SELECT * FROM CSVREAD('src/test/resources/META-INF/qltest/jdbc/users.csv')");
    } finally {
        closeQuietly(connection);
    }
}
 
开发者ID:kwon37xi,项目名称:freemarker-dynamic-ql-builder,代码行数:18,代码来源:FreemarkerDynamicQlBuilderJdbcTest.java

示例10: initConnectionPool

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
/**
 *
 *
 * @return
 * @throws ClassNotFoundException
 */
public H2Database initConnectionPool(boolean force) throws ClassNotFoundException {
  Class.forName(JDBC_EMBEDDED_DRIVER);

  if (force && connectionPool != null) {
    connectionPool.dispose();
  }

  if (connectionPool == null || force) {
    // *INDENT-OFF*
    connectionPool = JdbcConnectionPool.create(
        "jdbc:h2:"
        + dataPath.getAbsolutePath()
        + ";CREATE=TRUE", "sa", "sa");
    // *INDENT-ON*
    connectionPool.setMaxConnections(50);
  }

  return this;
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:26,代码来源:H2Database.java

示例11: Client

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
public Client(String databaseFileName, String address, int port) {

        online = true;

        jdbcConnectionPool = JdbcConnectionPool.create(
                "jdbc:h2:" + databaseFileName + ";" + DB_CONNECTION_MODIFIERS,
                "sa", "sa");
        jdbcConnectionPool.setMaxConnections(100);
        jdbcConnectionPool.setLoginTimeout(0);

        try {

            DaoFactory.initialize(
                    jdbcConnectionPool
            );

            DaoFactory.createSchema();

        } catch (DaoException e) {
            e.printStackTrace();
        }
        networkClient = new NetworkClientImpl(address, port);
    }
 
开发者ID:bedrin,项目名称:jsonde,代码行数:24,代码来源:Client.java

示例12: init

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
static void init()
{
  long l = Nxt.getIntProperty("nxt.dbCacheKB");
  if (l == 0L) {
    l = Runtime.getRuntime().maxMemory() / 2048L;
  }
  String str = Nxt.getStringProperty("nxt.dbUrl");
  if (!str.contains("CACHE_SIZE=")) {
    str = str + ";CACHE_SIZE=" + l;
  }
  Logger.logDebugMessage("Database jdbc url set to: " + str);
  cp = JdbcConnectionPool.create(str, "sa", "sa");
  cp.setMaxConnections(Nxt.getIntProperty("nxt.maxDbConnections"));
  cp.setLoginTimeout(Nxt.getIntProperty("nxt.dbLoginTimeout"));
  DbVersion.init();
}
 
开发者ID:stevedoe,项目名称:nxt-client,代码行数:17,代码来源:Db.java

示例13: testGetDataSource

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
@Test
public void testGetDataSource() throws Exception {
    // Create initial context
    System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
    System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");
    // already tried System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");
    InitialContext ic = new InitialContext();

    ic.createSubcontext("java:");
    ic.createSubcontext("java:/comp");
    ic.createSubcontext("java:/comp/env");
    ic.createSubcontext("java:/comp/env/jdbc");

    JdbcConnectionPool ds = JdbcConnectionPool.create("jdbc:h2:file:/tmp/test.db;FILE_LOCK=NO;MVCC=TRUE;DB_CLOSE_ON_EXIT=TRUE", "sa", "sasasa");

    String jndiName = "java:/mydatasource";
    ic.bind(jndiName, ds);


    DataSource dataSource = RDBMSUtils.getDataSource(jndiName);
    assertEquals("org.h2.jdbcx.JdbcConnectionPool",dataSource.getClass().getCanonicalName());

}
 
开发者ID:lightblue-platform,项目名称:lightblue-rdbms,代码行数:24,代码来源:RDBMSUtilsTest.java

示例14: createRouteBuilder

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    dataSource = JdbcConnectionPool.create("jdbc:h2:mem:" + getTestMethodName(), "sa", "sa");
    assertThatTableDoesNotExist("repository");
    RepositoryManagerFactory repositoryManagerFactory = new RepositoryManagerFactory();
    repositoryManagerFactory.setDataSource(dataSource);
    messageStore = new JDBCMessageStore();
    messageStore.setUuidGenerator(new UUIDGenerator());
    messageStore.setRepositoryManager(repositoryManagerFactory.createRepositoryManager());
    messageStore.init();
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from(MessageStore.DEFAULT_MESSAGE_STORE_ENDPOINT)
                .bean(messageStore,"store")
                .bean(messageStore,"storeMessage")
            .routeId("testPostsgresMessageStore");
        }
    };
}
 
开发者ID:jentrata,项目名称:jentrata,代码行数:21,代码来源:JDBCMessageStoreTest.java

示例15: openAmberDb

import org.h2.jdbcx.JdbcConnectionPool; //导入依赖的package包/类
public static AmberSession openAmberDb(String dbUrl, String dbUser, String dbPassword, String rootPath) throws InstantiationException, IllegalAccessException,
        ClassNotFoundException, SQLException {
    DataSource ds = null;
    AmberSession sess = null;

    try {
        MysqlDataSource mds = new MysqlDataSource();
        mds.setURL(dbUrl);
        mds.setUser(dbUser);
        mds.setPassword(dbPassword);
        ds = mds;
        sess = openAmberDb(ds, rootPath);
    } catch (Throwable e) {
        h2Test = true;
        // This is for build integration site which does not have
        // direct access to the mysql data source.
        DriverManager.registerDriver(new org.h2.Driver());
        dbUrl = "jdbc:h2:" + Paths.get(".").resolve("graph") + ";MVCC=true;DATABASE_TO_UPPER=false";
        dbUser = "garfield";
        dbPassword = "odde";
        ds = JdbcConnectionPool.create(dbUrl, dbUser, dbPassword);
        sess = openAmberDb(ds, rootPath);
    }

    return sess;
}
 
开发者ID:nla,项目名称:amberdb,代码行数:27,代码来源:AmberDbFactory.java


注:本文中的org.h2.jdbcx.JdbcConnectionPool类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。