本文整理汇总了Java中com.zaxxer.hikari.HikariConfig.setUsername方法的典型用法代码示例。如果您正苦于以下问题:Java HikariConfig.setUsername方法的具体用法?Java HikariConfig.setUsername怎么用?Java HikariConfig.setUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.zaxxer.hikari.HikariConfig
的用法示例。
在下文中一共展示了HikariConfig.setUsername方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupPool
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private void setupPool() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://" + this.credentials.getHostname() + ":" + this.credentials.getPort() + "/" + this.credentials.getDatabaseName());
config.setDriverClassName("com.mysql.jdbc.Driver");
config.setUsername(this.credentials.getUsername());
config.setPassword(this.credentials.getPassword());
config.setMinimumIdle(this.minimumConnections);
config.setMaximumPoolSize(this.maximumConnections);
config.setConnectionTimeout(this.connectionTimeout);
try {
this.dataSource = new HikariDataSource(config);
}
catch (Exception e) {
Bukkit.getLogger().severe("[ZorahPractice] - Unable to establish MySQL connection, plugin disabled.");
Bukkit.getServer().getPluginManager().disablePlugin(PracticePlugin.getInstance());
}
}
示例2: hikariConfig
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Bean
public HikariConfig hikariConfig() {
log.info("Creating HikariConfig with:\n* username: {}\n* jdbcUrl: {}", databaseProperties.getUsername(), databaseProperties.getUrl());
HikariConfig config = new HikariConfig();
config.setDriverClassName(databaseProperties.getDriverClassName());
config.setJdbcUrl(databaseProperties.getUrl());
config.setUsername(databaseProperties.getUsername());
config.setPassword(databaseProperties.getPassword());
config.setMaximumPoolSize(databaseProperties.getMaximumPoolSize());
config.setIdleTimeout(databaseProperties.getIdleTimeout());
config.setConnectionTestQuery(databaseProperties.getConnectionTestQuery());
config.setPoolName(databaseProperties.getPoolName());
config.setMetricsTrackerFactory(prometheusMetricsTrackerFactory());
config.setDataSourceProperties(dataSourceProperties());
return config;
}
示例3: getDataSourceFromConfig
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
public static HikariDataSource getDataSourceFromConfig(
Config conf
, MetricRegistry metricRegistry
, HealthCheckRegistry healthCheckRegistry) {
HikariConfig jdbcConfig = new HikariConfig();
jdbcConfig.setPoolName(conf.getString("poolName"));
jdbcConfig.setMaximumPoolSize(conf.getInt("maximumPoolSize"));
jdbcConfig.setMinimumIdle(conf.getInt("minimumIdle"));
jdbcConfig.setJdbcUrl(conf.getString("jdbcUrl"));
jdbcConfig.setUsername(conf.getString("username"));
jdbcConfig.setPassword(conf.getString("password"));
jdbcConfig.addDataSourceProperty("cachePrepStmts", conf.getBoolean("cachePrepStmts"));
jdbcConfig.addDataSourceProperty("prepStmtCacheSize", conf.getInt("prepStmtCacheSize"));
jdbcConfig.addDataSourceProperty("prepStmtCacheSqlLimit", conf.getInt("prepStmtCacheSqlLimit"));
jdbcConfig.addDataSourceProperty("useServerPrepStmts", conf.getBoolean("useServerPrepStmts"));
// Add HealthCheck
jdbcConfig.setHealthCheckRegistry(healthCheckRegistry);
// Add Metrics
jdbcConfig.setMetricRegistry(metricRegistry);
return new HikariDataSource(jdbcConfig);
}
示例4: MySQLThreadPool
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private MySQLThreadPool(FileConfiguration config) {
HikariConfig poolConf = new HikariConfig();
poolConf.setJdbcUrl("jdbc:mysql://"
+ config.getString("mysql.host", "localhost")
+ ":"
+ config.getInt("mysql.port", 3306)
+ "/"
+ config.getString("mysql.database", "Stats4")
+ config.getString("mysql.extra-opts", ""));
poolConf.setUsername(config.getString("mysql.username"));
poolConf.setPassword(config.getString("mysql.password"));
poolConf.addDataSourceProperty("cachePrepStmts", true);
poolConf.addDataSourceProperty("prepStmtCacheSize", "256");
poolConf.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
poolConf.addDataSourceProperty("useServerPrepStmts", true);
poolConf.addDataSourceProperty("useLocalSessionState", true);
poolConf.addDataSourceProperty("useLocalTransactionState", true);
poolConf.addDataSourceProperty("rewriteBatchedStatements", true);
poolConf.addDataSourceProperty("cacheResultSetMetadata", true);
poolConf.addDataSourceProperty("cacheServerConfiguration", true);
poolConf.addDataSourceProperty("elideSetAutoCommits", true);
// poolConf.addDataSourceProperty("maintainTimeStats", false);
this.dataSource = new HikariDataSource(poolConf);
}
示例5: 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);
}
示例6: dataSource
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Bean(destroyMethod = "close") // Should happen anyway, but worth calling out
@Primary
public HikariDataSource dataSource() throws ParserConfigurationException, IOException, SAXException, ParseException {
ApplicationConfig appConfig = applicationConfig();
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl("jdbc:" + appConfig.getDbUrl() + "/" + appConfig.getDbName());
hikariConfig.setUsername(appConfig.getDbUser());
hikariConfig.setPassword(appConfig.getDbPassword());
hikariConfig.setMaximumPoolSize(appConfig.getThreadLimit());
hikariConfig.setInitializationFailTimeout(30000);
if(appConfig.isDbIgnoreSSLWarn()) {
hikariConfig.addDataSourceProperty("useSSL", false);
}
return new HikariDataSource(hikariConfig);
}
示例7: setUpClass
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@BeforeClass
public static void setUpClass() throws ParserConfigurationException, IOException, SAXException, SQLException, LiquibaseException {
ApplicationConfig config = ConfigurationBuilder.createBuilder().loadXMLConfiguration().getConfiguration();
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl("jdbc:" + config.getDbUrl() + "/" + config.getDbName());
hikariConfig.setUsername(config.getDbUser());
hikariConfig.setPassword(config.getDbPassword());
hikariConfig.setMaximumPoolSize(config.getThreadLimit());
if(config.isDbIgnoreSSLWarn()) {
hikariConfig.addDataSourceProperty("useSSL", false);
}
dataSource = new HikariDataSource(hikariConfig);
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(dataSource.getConnection()));
Liquibase liquibase = new Liquibase("db/changelog/db.changelog-master.yaml", new ClassLoaderResourceAccessor(), database);
liquibase.update(new Contexts(), new LabelExpression());
}
示例8: createDataSource
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private static DataSource createDataSource(String[] args) {
final HikariConfig config = new HikariConfig();
final String dbName = args[0];
final String username = args[1];
final String password = args[2];
log().info("Start `DataSource` creation. The following parameters will be used:");
final String dbUrl = format(DB_URL_FORMAT, getDbUrlPrefix(), dbName);
config.setJdbcUrl(dbUrl);
log().info("JDBC URL: {}", dbUrl);
config.setUsername(username);
log().info("Username: {}", username);
config.setPassword(password);
log().info("Password: {}", password);
final DataSource dataSource = new HikariDataSource(config);
return dataSource;
}
示例9: createDataSource
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private static DataSource createDataSource(String[] args) {
final HikariConfig config = new HikariConfig();
final String instanceConnectionName = args[0];
final String dbName = args[1];
final String username = args[2];
final String password = args[3];
log().info("Start `DataSource` creation. The following parameters will be used:");
final String dbUrl = format(DB_URL_FORMAT, getDbUrlPrefix(), dbName, instanceConnectionName);
config.setJdbcUrl(dbUrl);
log().info("JDBC URL: {}", dbUrl);
config.setUsername(username);
log().info("Username: {}", username);
config.setPassword(password);
log().info("Password: {}", password);
final DataSource dataSource = new HikariDataSource(config);
return dataSource;
}
示例10: createDataSource
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private static DataSource createDataSource() {
final HikariConfig config = new HikariConfig();
final String instanceConnectionName = properties.getProperty("db.instance");
final String dbName = properties.getProperty("db.name");
final String username = properties.getProperty("db.username");
final String password = properties.getProperty("db.password");
log().info("Start `DataSource` creation. The following parameters will be used:");
final String dbUrl = format(DB_URL_FORMAT, getDbUrlPrefix(), dbName, instanceConnectionName);
config.setJdbcUrl(dbUrl);
log().info("JDBC URL: {}", dbUrl);
config.setUsername(username);
log().info("Username: {}", username);
config.setPassword(password);
log().info("Password: {}", password);
final DataSource dataSource = new HikariDataSource(config);
return dataSource;
}
示例11: createDataSource
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private DataSource createDataSource() {
final HikariConfig config = new HikariConfig();
final String prefix = DB_CONFIG_PROPERTIES.getProperty("db.prefix");
final String dbName = DB_CONFIG_PROPERTIES.getProperty("db.name");
final String username = DB_CONFIG_PROPERTIES.getProperty("db.username");
final String password = DB_CONFIG_PROPERTIES.getProperty("db.password");
final String host = DB_CONFIG_PROPERTIES.getProperty("db.host");
final String port = DB_CONFIG_PROPERTIES.getProperty("db.port");
LOGGER.info("Start `DataSource` creation. The following parameters will be used:");
final String dbUrl = format(DB_URL_FORMAT, prefix, host, port, dbName);
config.setJdbcUrl(dbUrl);
LOGGER.info("JDBC URL: {}", dbUrl);
config.setUsername(username);
LOGGER.info("Username: {}", username);
config.setPassword(password);
LOGGER.info("Password: {}", password);
final DataSource dataSource = new HikariDataSource(config);
return dataSource;
}
示例12: persistentListen
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private static void persistentListen(ObjectMapper objectMapper, Listener<SalesOrderPlaced> listener) throws IOException {
final HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl(JDBC_URL);
hikariConfig.setUsername(JDBC_USERNAME);
hikariConfig.setPassword(JDBC_PASSWORD);
final DataSource dataSource = new HikariDataSource(hikariConfig);
final JdbcCursorManager cursorManager = new JdbcCursorManager(dataSource, "fahrschein-demo");
final NakadiClient nakadiClient = NakadiClient.builder(NAKADI_URI)
.withAccessTokenProvider(new ZignAccessTokenProvider())
.withCursorManager(cursorManager)
.build();
final List<Partition> partitions = nakadiClient.getPartitions(SALES_ORDER_SERVICE_ORDER_PLACED);
nakadiClient.stream(SALES_ORDER_SERVICE_ORDER_PLACED)
.readFromBegin(partitions)
.withObjectMapper(objectMapper)
.listen(SalesOrderPlaced.class, listener);
}
示例13: 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);
}
示例14: 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);
}
示例15: 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);
}