本文整理汇总了Java中com.zaxxer.hikari.HikariConfig.setPassword方法的典型用法代码示例。如果您正苦于以下问题:Java HikariConfig.setPassword方法的具体用法?Java HikariConfig.setPassword怎么用?Java HikariConfig.setPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.zaxxer.hikari.HikariConfig
的用法示例。
在下文中一共展示了HikariConfig.setPassword方法的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: 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);
}
示例4: createDataSource
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public DataSource createDataSource(DataSourceConfig dataSourceConfig) {
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl(dataSourceConfig.getUrl());
hikariConfig.setUsername(dataSourceConfig.getUser());
hikariConfig.setPassword(dataSourceConfig.getPassword());
hikariConfig.addDataSourceProperty("cachePrepStmts", dataSourceConfig.isCachePrepStmts());
hikariConfig.addDataSourceProperty("prepStmtCacheSize", dataSourceConfig.getPrepStmtCacheSize());
hikariConfig.addDataSourceProperty("prepStmtCacheSqlLimit", dataSourceConfig.getPrepStmtCacheSqlLimit());
hikariConfig.setDriverClassName(dataSourceConfig.getDriverClassName());
hikariConfig.setPoolName(dataSourceConfig.getPoolName());
if (dataSourceConfig.getConnectionInitSql() != null) {
hikariConfig.setConnectionInitSql(dataSourceConfig.getConnectionInitSql());
}
hikariConfig.setMaximumPoolSize(dataSourceConfig.getMaximumPoolSize());
return new HikariDataSource(hikariConfig);
}
示例5: 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);
}
示例6: testConnection
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public void testConnection(String url, String username, String password) throws Exception {
HikariConfig config = new HikariConfig();
config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
config.setJdbcUrl(url);
config.setUsername(username);
config.setPassword(password);
config.setPoolName("easyrecPool");
config.addDataSourceProperty("url", url);
HikariDataSource ds = new HikariDataSource(config);
setDataSource(ds);
sqlScriptService.setDataSource(ds);
boolean tablesOk = false;
DatabaseMetaDataCallback callback = new DatabaseMetaDataCallback() {
public Object processMetaData(DatabaseMetaData dbmd) throws SQLException, MetaDataAccessException {
ResultSet rs = dbmd.getTables(null, null, "operator", null);
return rs.next();
}
};
tablesOk = (Boolean) JdbcUtils.extractDatabaseMetaData(ds, callback);
}
示例7: 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;
}
示例8: 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;
}
示例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);
}
示例10: initConnection
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private void initConnection() throws Exception {
HikariConfig config = new HikariConfig();
config.setPoolName("Parties");
config.setJdbcUrl(Variables.storage_settings_mysql_url);
config.setUsername(Variables.storage_settings_mysql_username);
config.setPassword(Variables.storage_settings_mysql_password);
config.setMaximumPoolSize(Variables.storage_settings_mysql_poolsize);
config.setMinimumIdle(Variables.storage_settings_mysql_poolsize);
config.setMaxLifetime(Variables.storage_settings_mysql_connlifetime);
config.setIdleTimeout(Variables.storage_settings_mysql_conntimeout);
// Properties: https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html
config.addDataSourceProperty("cachePreStmts", "true"); // Enable Prepared Statement caching
config.addDataSourceProperty("prepStmtCacheSize", "25"); // How many PS cache, default: 25
config.addDataSourceProperty("useServerPrepStmts", "true"); // If supported use PS server-side
config.addDataSourceProperty("useLocalSessionState", "true"); // Enable setAutoCommit
config.addDataSourceProperty("useLocalTransactionState", "true"); // Enable commit/rollbacks
hikariDataSource = new HikariDataSource(config);
}
示例11: initDatabase
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
public void initDatabase() {
LOGGER.debug("Connecting to database");
HikariConfig databaseConfig = new HikariConfig();
String driverType = config.get("driverType");
String host = config.get("host");
String port = config.get("port");
String database = config.get("database");
String jdbcUrl = "jdbc:" + driverType + "://" + host + ':' + port + '/' + database;
databaseConfig.setJdbcUrl(jdbcUrl);
databaseConfig.setUsername("root");
databaseConfig.setPassword(config.get("password"));
databaseConfig.setConnectionTimeout(Long.parseLong(config.get("connectionTimeout")));
dataSource = new HikariDataSource(databaseConfig);
}
示例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);
}
示例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;
}
示例14: createHikari
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
public static HikariDataSource createHikari(String url, String user, String pass, Properties dsProps)
{
HikariConfig config = new HikariConfig();
config.setJdbcUrl(url);
config.setUsername(user);
config.setPassword(pass);
config.setDataSourceProperties(dsProps);
LOGGER.info("creating hikaricp datasource. using jdbc url {}", config.getJdbcUrl());
return new HikariDataSource(config);
}
示例15: createDataSource
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Bean
public DataSource createDataSource() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(this.url);
config.setUsername(this.username);
config.setPassword(this.password);
config.addDataSourceProperty("poolName", this.poolName);
config.addDataSourceProperty("connectionTimeout", this.connectionTimeout);
config.addDataSourceProperty("autoCommit", "false");
return new HikariDataSource(config);
}