本文整理汇总了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;
}
示例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();
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}