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


Java HikariConfig.setDriverClassName方法代码示例

本文整理汇总了Java中com.zaxxer.hikari.HikariConfig.setDriverClassName方法的典型用法代码示例。如果您正苦于以下问题:Java HikariConfig.setDriverClassName方法的具体用法?Java HikariConfig.setDriverClassName怎么用?Java HikariConfig.setDriverClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.zaxxer.hikari.HikariConfig的用法示例。


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

示例1: getDefaultHikariConfig

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Nonnull
public static HikariConfig getDefaultHikariConfig() {
    final HikariConfig hikariConfig = new HikariConfig();

    //more database connections don't help with performance, so use a default value based on available cores
    //http://www.dailymotion.com/video/x2s8uec_oltp-performance-concurrent-mid-tier-connections_tech
    hikariConfig.setMaximumPoolSize(Math.max(Runtime.getRuntime().availableProcessors(), 4));

    //timeout the validation query (will be done automatically through Connection.isValid())
    hikariConfig.setValidationTimeout(3000);
    hikariConfig.setConnectionTimeout(10000);
    hikariConfig.setAutoCommit(false);

    hikariConfig.setDriverClassName("org.postgresql.Driver");

    return hikariConfig;
}
 
开发者ID:napstr,项目名称:SqlSauce,代码行数:18,代码来源:DatabaseConnection.java

示例2: MySQL

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
public MySQL(Jecon jecon) {
	super.config = jecon.getConfigStruct();

	jecon.getLogger().info("Connect to MySQL.");

	HikariConfig hikariConfig = new HikariConfig();
	hikariConfig.setDriverClassName("com.mysql.jdbc.Driver");

	// for Performance
	hikariConfig.addDataSourceProperty("cacheServerConfiguration", "true");
	hikariConfig.addDataSourceProperty("alwaysSendSetIsolation", "false");
	hikariConfig.addDataSourceProperty("useLocalSessionState", "true");
	hikariConfig.addDataSourceProperty("elideSetAutoCommits", "true");
	hikariConfig.addDataSourceProperty("maintainTimeStats", "false");
	hikariConfig.addDataSourceProperty("cachePrepStmts", "true");
	hikariConfig.addDataSourceProperty("prepStmtCacheSize", "250");
	hikariConfig.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");

	super.setup(jecon, hikariConfig);
}
 
开发者ID:HimaJyun,项目名称:Jecon,代码行数:21,代码来源:MySQL.java

示例3: enableDatabaseMySQLTest

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Test
public void enableDatabaseMySQLTest() {
    try {
        final DB database = DB.newEmbeddedDB(3306);
        database.start();
        try (Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/?user=root&password=")) {
            try (Statement statement = conn.createStatement()) {
                statement.executeUpdate("CREATE DATABASE db");
            }
        }
        final HikariConfig config = new HikariConfig();
        config.setDriverClassName("com.mysql.jdbc.Driver");
        config.setConnectionTestQuery("SELECT 1");
        config.setJdbcUrl("jdbc:mysql://localhost:3306/db");
        config.setMaxLifetime(60000);
        config.setIdleTimeout(45000);
        config.setMaximumPoolSize(50);
        final HikariDataSource ds = new HikariDataSource(config);
        ds.close();
        database.stop();
    } catch (final Exception ex) {
        Logger.getLogger(this.getClass().getSimpleName()).log(Level.WARNING, "Failed to enable database.", ex);
        Assert.fail();
    }
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:26,代码来源:DatabaseIT.java

示例4: ExtensionHikariConnectionContext

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
/**
 * Initializes a new databaseConnectionContext for the given url, userName and password
 *
 * @param url      url
 * @param userName userNames
 * @param password password
 */
private ExtensionHikariConnectionContext(String driver, String url, String userName, String password, SQlRetriever retriever) {
    super();
    this.retriever = retriever;
    final HikariConfig config = new HikariConfig();
    config.setDriverClassName(driver);
    config.setConnectionTestQuery("SELECT 1");
    config.setJdbcUrl(url);
    if (userName != null)
        config.setUsername(userName);
    if (password != null)
        config.setPassword(password);
    config.addDataSourceProperty("cachePrepStmts", "true");
    config.addDataSourceProperty("prepStmtCacheSize", "250");
    config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
    if (driver.equals(SQLITE_DRIVER))
        config.setMaximumPoolSize(1);
    else
        config.setMaximumPoolSize(10);
    this.ds = new HikariDataSource(config);
    Logger.getLogger(this.getClass().getSimpleName()).log(Level.INFO, "Connected to " + url);
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:29,代码来源:ExtensionHikariConnectionContext.java

示例5: setUp

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@BeforeClass
public void setUp() throws SQLException {
    Connection connection = DriverManager.getConnection(databaseUrl + ";create=true");
    Statement statement = connection.createStatement();
    statement.executeUpdate(CREATE_MB_COORDINATOR_HEARTBEAT_TABLE);
    statement.executeUpdate(CREATE_MB_NODE_HEARTBEAT_TABLE);
    connection.close();

    Map<String, String> rdbmsCoordinationOptions = new HashMap<>();
    rdbmsCoordinationOptions.put(RdbmsCoordinationConstants.NODE_IDENTIFIER, nodeOneId);
    rdbmsCoordinationOptions.put(RdbmsCoordinationConstants.HEARTBEAT_INTERVAL, "5000");
    rdbmsCoordinationOptions.put(RdbmsCoordinationConstants.COORDINATOR_ENTRY_CREATION_WAIT_TIME, "3000");

    HikariConfig hikariDatasourceConfig = new HikariConfig();
    hikariDatasourceConfig.setJdbcUrl(databaseUrl);
    hikariDatasourceConfig.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver");
    hikariDatasourceConfig.setAutoCommit(false);
    DataSource datasource = new HikariDataSource(hikariDatasourceConfig);

    RdbmsCoordinationDaoImpl rdbmsCoordinationDaoImpl = new RdbmsCoordinationDaoImpl(datasource);
    rdbmsCoordinationStrategy =
            new RdbmsCoordinationStrategy(rdbmsCoordinationDaoImpl, rdbmsCoordinationOptions);
    rdbmsCoordinationStrategy.start();
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:25,代码来源:RdbmsCoordinationStrategyTest.java

示例6: ExtensionHikariConnectionContext

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
/**
 * Initializes a new databaseConnectionContext for the given url, userName and password
 *
 * @param url      url
 * @param userName userName
 * @param password password
 */
private ExtensionHikariConnectionContext(String driver, String url, String userName, String password, SQlRetriever retriever) {
    super();
    this.retriever = retriever;
    final HikariConfig config = new HikariConfig();
    config.setDriverClassName(driver);
    config.setConnectionTestQuery("SELECT 1");
    config.setJdbcUrl(url);
    if (userName != null)
        config.setUsername(userName);
    if (password != null)
        config.setPassword(password);
    config.addDataSourceProperty("cachePrepStmts", "true");
    config.addDataSourceProperty("prepStmtCacheSize", "250");
    config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
    if (driver.equals(SQLITE_DRIVER))
        config.setMaximumPoolSize(1);
    else
        config.setMaximumPoolSize(10);
    this.ds = new HikariDataSource(config);
    Logger.getLogger(this.getClass().getSimpleName()).log(Level.INFO, "Connected to " + url);
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:29,代码来源:ExtensionHikariConnectionContext.java

示例7: enableDatabaseSQLiteTest

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Test
public void enableDatabaseSQLiteTest() {
    try {
        final HikariConfig config = new HikariConfig();
        config.setDriverClassName("org.sqlite.JDBC");
        config.setConnectionTestQuery("SELECT 1");
        config.setJdbcUrl("jdbc:sqlite:PetBlocks.db");
        config.setMaxLifetime(60000);
        config.setIdleTimeout(45000);
        config.setMaximumPoolSize(50);
        final HikariDataSource ds = new HikariDataSource(config);
        ds.close();
    } catch (final Exception ex) {
        Logger.getLogger(this.getClass().getSimpleName()).log(Level.WARNING, "Failed to enable database.", ex);
        Assertions.fail(ex);
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:18,代码来源:DatabaseTest.java

示例8: enableDatabaseMySQLTest

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Test
public void enableDatabaseMySQLTest() {
    try {
        final DB database = DB.newEmbeddedDB(3306);
        database.start();
        try (Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/?user=root&password=")) {
            try (Statement statement = conn.createStatement()) {
                statement.executeUpdate("CREATE DATABASE db");
            }
        }

        final HikariConfig config = new HikariConfig();
        config.setDriverClassName("com.mysql.jdbc.Driver");
        config.setConnectionTestQuery("SELECT 1");
        config.setJdbcUrl("jdbc:mysql://localhost:3306/db");
        config.setMaxLifetime(60000);
        config.setIdleTimeout(45000);
        config.setMaximumPoolSize(50);
        final HikariDataSource ds = new HikariDataSource(config);
        ds.close();
        database.stop();
    } catch (final Exception ex) {
        Logger.getLogger(this.getClass().getSimpleName()).log(Level.WARNING, "Failed to enable database.", ex);
        Assertions.fail(ex);
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:27,代码来源:DatabaseTest.java

示例9: start

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public void start() {
	HikariConfig config = new HikariConfig();
	config.setJdbcUrl(this.conURL);
	config.setUsername(this.username);
	config.setPassword(this.password);
	config.setDriverClassName(this.driverName);
	config.setMaximumPoolSize(max);
	config.setMinimumIdle(min);
	if (this.testSql != null && this.testSql.trim().length() > 0) {
		config.setConnectionTestQuery(testSql);
	}
	config.setPoolName("HikariCPPool[" + username + "]");
	config.addDataSourceProperty("cachePrepStmts", AppProperties.get("HikariCPPool_cachePrepStmts", "true"));
	config.addDataSourceProperty("prepStmtCacheSize", AppProperties.get("HikariCPPool_prepStmtCacheSize", "250"));
	config.addDataSourceProperty("prepStmtCacheSqlLimit",
			AppProperties.get("HikariCPPool_prepStmtCacheSqlLimit", "2048"));
	config.setConnectionTimeout(AppProperties.getAsInt("HikariCPPool_connectionTimeout", 30000));
	config.setIdleTimeout(AppProperties.getAsInt("HikariCPPool_idleTimeout", 600000));
	config.setMaxLifetime(AppProperties.getAsInt("HikariCPPool_maxLifetime", 1800000));
	// HikariDataSource ds = new HikariDataSource(config);
	// this.datasource=ds.getDataSource();
	this.datasource = new HikariDataSource(config);
}
 
开发者ID:jbeetle,项目名称:BJAF3.x,代码行数:25,代码来源:HikariCPPool.java

示例10: dataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Bean(destroyMethod = "close")
public DataSource dataSource() {
    log.debug("Configuring Datasource");
    if (dataSourcePropertyResolver.getProperty("url") == null) {
        log.error("Your database connection pool configuration is incorrect! The application" +
                " cannot start. Please check your Spring profile, current profiles are: {}",
            Arrays.toString(env.getActiveProfiles()));
        throw new ApplicationContextException("Database connection pool is not configured correctly");
    }

    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setDriverClassName(dataSourcePropertyResolver.getProperty("dataSourceClassName"));
    hikariConfig.setJdbcUrl(dataSourcePropertyResolver.getProperty("url"));
    hikariConfig.setUsername(dataSourcePropertyResolver.getProperty("username"));
    hikariConfig.setPassword(dataSourcePropertyResolver.getProperty("password"));
    return new HikariDataSource(hikariConfig);
}
 
开发者ID:aksakalli,项目名称:todo-spring-angular,代码行数:18,代码来源:DatabaseConfiguration.java

示例11: dataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
/**
 * Prepare @{link DataSource} to access underlying database. We will use HikariCP because currently this is a industry tsndartd
 *
 * @param environment Interface representing the environment in which the current application is running.
 */
@Bean(destroyMethod = "close")
DataSource dataSource(Environment environment) {
    HikariConfig dataSourceConfig = new HikariConfig();
    dataSourceConfig.setDriverClassName(environment.getRequiredProperty("db.driver"));
    dataSourceConfig.setJdbcUrl(environment.getRequiredProperty("db.url"));
    dataSourceConfig.setUsername(environment.getRequiredProperty("db.username"));
    dataSourceConfig.setPassword(environment.getRequiredProperty("db.password"));
    return new HikariDataSource(dataSourceConfig);
}
 
开发者ID:Logicify,项目名称:d2g-api,代码行数:15,代码来源:RepositoryConfiguration.java

示例12: getDataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Bean
@Primary
public DataSource getDataSource() {
    HikariConfig config = new HikariConfig();
    config.setDriverClassName("com.mysql.jdbc.Driver");
    config.setJdbcUrl("jdbc:mysql://localhost:3306/test");
    config.setUsername("root");
    config.setPassword("root");
    config.setMaximumPoolSize(500);
    config.setMinimumIdle(10);
    return new HikariDataSource(config);
}
 
开发者ID:SkywalkingTest,项目名称:Agent-Benchmarks,代码行数:13,代码来源:DataSourceConfiguration.java

示例13: createLocalOracleDb

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private Database createLocalOracleDb() {
	HikariConfig config = new HikariConfig();
	config.setJdbcUrl("jdbc:oracle:thin:@localhost:1521:XE");
	config.setUsername("test");
	config.setPassword("somepwd");
	config.setAutoCommit(false);
	config.setDriverClassName("oracle.jdbc.driver.OracleDriver");
	Database oracleDb = new Database(new HikariDataSource(config));
	return oracleDb;
}
 
开发者ID:jaregu,项目名称:queries,代码行数:11,代码来源:SampleQueries.java

示例14: setupPool

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private void setupPool() {
    HikariConfig config = new HikariConfig();
    config.setJdbcUrl("jdbc:mysql://" + hostname + ":" + port + "/" + database);
    config.setDriverClassName("com.mysql.jdbc.Driver");
    config.setUsername(username);
    config.setPassword(password);
    config.setMinimumIdle(minimumIdle);
    config.setMaximumPoolSize(poolSize);
    config.setConnectionTimeout(connectionTimeout);
    config.setConnectionTestQuery(testQuery);
    config.addDataSourceProperty("cachePrepStmts", "true");
    config.addDataSourceProperty("prepStmtCacheSize", "250");
    config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
    dataSource = new HikariDataSource(config);
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:16,代码来源:ConnectionPoolManager.java

示例15: createDataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private static DataSource createDataSource() {
    HikariConfig hikariDataSourceConfig = new HikariConfig();
    hikariDataSourceConfig.setJdbcUrl(DATABASE_URL);
    hikariDataSourceConfig.setDriverClassName(DRIVER_CLASS_NAME);
    hikariDataSourceConfig.setAutoCommit(false);
    return new HikariDataSource(hikariDataSourceConfig);
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:8,代码来源:DbUtil.java


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