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


Java HikariConfig.setAutoCommit方法代码示例

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


在下文中一共展示了HikariConfig.setAutoCommit方法的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: 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

示例3: dataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Bean
@ConditionalOnMissingBean
public DataSource dataSource() {
    HikariConfig configuration = new HikariConfig();
    configuration.setJdbcUrl(url);
    configuration.setUsername(username);
    configuration.setPassword(password);
    configuration.setAutoCommit(false);
    configuration.setMaximumPoolSize(maxPoolSize);
    configuration.setConnectionTimeout(connectionTimeout);
    configuration.setMaxLifetime(maxLifetime);
    Properties properties = new Properties();
    properties.setProperty("cachePrepStmts", cachePrepStmts);
    properties.setProperty("prepStmtCacheSize", prepStmtCacheSize);
    properties.setProperty("prepStmtCacheSqlLimit", prepStmtCacheSqlLimit);
    properties.setProperty("useServerPrepStmts", useServerPrepStmts);
    configuration.setDataSourceProperties(properties);
    configuration.setConnectionInitSql("SET NAMES " + connectionCharacter);
    return new HikariDataSource(configuration);
}
 
开发者ID:superkoh,项目名称:k-framework,代码行数:21,代码来源:MybatisAutoConfiguration.java

示例4: setup

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
protected void setup(Jecon jecon, HikariConfig hikariConfig) {
	this.jecon = jecon;
	if (config == null) {
		config = jecon.getConfigStruct();
	}
	this.prefix = config.getDbConfig().prefix;

	hikariConfig.setJdbcUrl(config.getDbConfig().url);
	hikariConfig.setInitializationFailFast(true);
	hikariConfig.setAutoCommit(true);
	hikariConfig.setConnectionInitSql("/* Jecon */SELECT 1");

	if (config.getDbConfig().poolSize > 0) {
		hikariConfig.setMaximumPoolSize(config.getDbConfig().poolSize);
	}
	if (config.getDbConfig().timeout > 0) {
		hikariConfig.setIdleTimeout(config.getDbConfig().timeout);
	}

	hikariConfig.setDataSourceProperties(config.getDbConfig().propaties);

	// HikariDataSourceをインスタンス化
	this.hikariDc = new HikariDataSource(hikariConfig);

	this.createTable();
}
 
开发者ID:HimaJyun,项目名称:Jecon,代码行数:27,代码来源:Database.java

示例5: provide

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public DataSource provide() {
    LOGGER.debug("{}", this);
    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(jdbcUrl);
    config.setUsername(username);
    config.setPassword(password);
    config.setAutoCommit(autoCommit);
    config.setMaximumPoolSize(maximumPoolSize);
    config.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
    config.addDataSourceProperty("cachePrepStmts", "true");
    config.addDataSourceProperty("prepStmtCacheSize", "250");
    config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");

    HikariDataSource dataSource = new HikariDataSource(config);
    LOGGER.debug("provide DataSource {}", dataSource);

    return dataSource;
}
 
开发者ID:protoxme,项目名称:protox-webapp-archetype,代码行数:20,代码来源:DataSourceFactory.java

示例6: getDataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
public static DataSource getDataSource() {

        HikariConfig hikariDataSourceConfig = new HikariConfig();
        hikariDataSourceConfig.setJdbcUrl(DATABASE_URL);
        hikariDataSourceConfig.setAutoCommit(false);
        return new HikariDataSource(hikariDataSourceConfig);
    }
 
开发者ID:wso2,项目名称:message-broker,代码行数:8,代码来源:DbUtils.java

示例7: 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

示例8: getDataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private static DataSource getDataSource(BrokerConfiguration.DataSourceConfiguration dataSourceConfiguration) {
    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(dataSourceConfiguration.getUrl());
    config.setUsername(dataSourceConfiguration.getUser());
    config.setPassword(dataSourceConfiguration.getPassword());
    config.setAutoCommit(false);

    return new HikariDataSource(config);
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:10,代码来源:Main.java

示例9: build

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public ManagedDataSource build(final MetricRegistry metricRegistry, final String name) {
    final Properties properties = new Properties();
    for (final Map.Entry<String, String> property : this.properties.entrySet()) {
        properties.setProperty(property.getKey(), property.getValue());
    }

    final HikariConfig config = new HikariConfig();
    config.setMetricRegistry(metricRegistry);
    if (healthCheckRegistry != null) {
        config.setHealthCheckRegistry(healthCheckRegistry);
    }

    config.setAutoCommit(autoCommit);
    config.setDataSourceProperties(properties);
    if (datasourceClassName != null) {
        config.setDataSourceClassName(datasourceClassName);
    } else {
        config.setDriverClassName(driverClass);
    }

    config.setMaximumPoolSize(maxSize);
    minSize.ifPresent(config::setMinimumIdle);
    config.setPoolName(name);
    config.setUsername(user);
    config.setPassword(user != null && password == null ? "" : password);
    return new HikariManagedPooledDataSource(config);
}
 
开发者ID:nickbabcock,项目名称:dropwizard-hikaricp-benchmark,代码行数:29,代码来源:HikariDataSourceFactory.java

示例10: doBenchHikari

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private void doBenchHikari() throws Exception {
    HikariConfig config = new HikariConfig();
    config.setDataSource(new StubDataSource());
    config.setUsername("brettw");
    config.setPassword("");
    config.setMinimumIdle(0);
    config.setMaximumPoolSize(32);
    config.setConnectionTimeout(8000);
    config.setAutoCommit(false);
    DataSource ds = new HikariDataSource(config);
    doBench(ds);
    ((AutoCloseable) ds).close();
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:14,代码来源:Bench.java

示例11: apply

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public DataSourceHolder apply(SourceKey key)
{
	final HikariConfig newConfig = new HikariConfig(baseConfig);
	newConfig.setDriverClassName(driverClass);
	newConfig.setUsername(key.getUsername());
	newConfig.setPassword(key.getPassword());
	newConfig.setJdbcUrl(key.getUrl());
	//Fixed properties: (i.e. do not allow override in hikari.properties)
	newConfig.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
	newConfig.setAutoCommit(false);
	newConfig.setInitializationFailFast(false);
	newConfig.setThreadFactory(new ThreadFactory()
	{
		@Override
		public Thread newThread(final Runnable r)
		{
			return new Thread("CustomHikariThread")
			{
				@Override
				public void run()
				{
					ClassLoader oldLoader = getContextClassLoader();
					try
					{
						setContextClassLoader(DataSourceServiceImpl.class.getClassLoader());
						r.run();
					}
					catch( Throwable t )
					{
						setContextClassLoader(oldLoader);
					}
				}
			};
		}
	});

	return new DataSourceHolder(new HikariDataSource(newConfig), dialect);
}
 
开发者ID:equella,项目名称:Equella,代码行数:40,代码来源:DataSourceServiceImpl.java

示例12: getHikariConfig

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private HikariConfig getHikariConfig(AgroalDataSourceConfiguration dataSourceConfiguration) {
    if ( dataSourceConfiguration.isXA() ) {
        throw new UnsupportedOperationException( "Unsupported. Hikari does not support XA" );
    }

    HikariConfig hikariConfig = new HikariConfig();

    hikariConfig.setDataSourceJNDI( dataSourceConfiguration.jndiName() );
    hikariConfig.setLeakDetectionThreshold( poolConfiguration.leakTimeout().toMillis() );
    hikariConfig.setIdleTimeout( poolConfiguration.reapTimeout().toMillis() );
    hikariConfig.setValidationTimeout( poolConfiguration.validationTimeout().toMillis() );

    if ( factoryConfiguration.jdbcTransactionIsolation().isDefined() ) {
        hikariConfig.setTransactionIsolation( "TRANSACTION_" + factoryConfiguration.jdbcTransactionIsolation().name() );
    }

    hikariConfig.setJdbcUrl( factoryConfiguration.jdbcUrl() );
    hikariConfig.setAutoCommit( factoryConfiguration.autoCommit() );
    hikariConfig.setConnectionInitSql( factoryConfiguration.initialSql() );

    Principal principal = factoryConfiguration.principal();
    if ( principal != null ) {
        hikariConfig.setUsername( factoryConfiguration.principal().getName() );
    }
    for ( Object credential : factoryConfiguration.credentials() ) {
        if ( credential instanceof SimplePassword ) {
            hikariConfig.setPassword( ( (SimplePassword) credential ).getWord() );
        }
    }

    hikariConfig.setMaximumPoolSize( poolConfiguration.maxSize() );
    hikariConfig.setConnectionTimeout( poolConfiguration.acquisitionTimeout().toMillis() );
    hikariConfig.setDriverClassName( factoryConfiguration.driverClassName() );

    return hikariConfig;
}
 
开发者ID:agroal,项目名称:agroal,代码行数:37,代码来源:HikariUnderTheCovers.java

示例13: get

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public DataSource get() {
    HikariConfig config = new HikariConfig();

    config.setJdbcUrl("jdbc:mysql://localhost:3306/db_example");
    config.setUsername("tully");
    config.setPassword("tully");

    config.setMaximumPoolSize(10);
    config.setAutoCommit(false);
    config.setRegisterMbeans(true);

    return new HikariDataSource(config);
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_04,代码行数:15,代码来源:HikariCPDataSourceFactory.java

示例14: createLocalMariaDb

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private Database createLocalMariaDb() {
	HikariConfig config = new HikariConfig();
	config.setJdbcUrl(
			"jdbc:mariadb://localhost:3406/test?autoReconnect=true&?useUnicode=yes&characterEncoding=UTF-8");
	config.setUsername("test");
	config.setPassword("test");
	config.setAutoCommit(false);
	config.setDriverClassName("org.mariadb.jdbc.Driver");
	Database mariaDb = new Database(new HikariDataSource(config));
	return mariaDb;
}
 
开发者ID:jaregu,项目名称:queries,代码行数:12,代码来源:SampleQueries.java

示例15: 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


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