本文整理汇总了Java中org.apache.tomcat.jdbc.pool.PoolProperties.setJmxEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java PoolProperties.setJmxEnabled方法的具体用法?Java PoolProperties.setJmxEnabled怎么用?Java PoolProperties.setJmxEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tomcat.jdbc.pool.PoolProperties
的用法示例。
在下文中一共展示了PoolProperties.setJmxEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPoolProperties
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
public PoolProperties getPoolProperties() {
PoolProperties poolProperties = new PoolProperties();
poolProperties.setUrl("jdbc:postgresql://localhost:5432/chronica");
poolProperties.setDriverClassName("org.postgresql.Driver");
poolProperties.setUsername("chronica");
poolProperties.setPassword("chronica");
poolProperties.setJmxEnabled(true);
poolProperties.setTestWhileIdle(false);
poolProperties.setTestOnBorrow(true);
poolProperties.setValidationQuery("SELECT 1");
poolProperties.setTestOnReturn(false);
poolProperties.setValidationInterval(30000);
poolProperties.setTimeBetweenEvictionRunsMillis(30000);
poolProperties.setMaxActive(100);
poolProperties.setInitialSize(10);
poolProperties.setMaxWait(10000);
poolProperties.setRemoveAbandonedTimeout(60);
poolProperties.setMinEvictableIdleTimeMillis(30000);
poolProperties.setMinIdle(10);
poolProperties.setLogAbandoned(true);
poolProperties.setRemoveAbandoned(true);
poolProperties.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
return poolProperties;
}
示例2: getTomcatDataSource
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
/**
* Tomcat DataSource 를 빌드합니다.
*
* @param driverClass the driver class
* @param url the url
* @param username the username
* @param passwd the passwd
* @return the tomcat kr.hconnect.data source
*/
protected DataSource getTomcatDataSource(String driverClass, String url, String username, String passwd) {
PoolProperties p = new PoolProperties();
p.setUrl(url);
p.setDriverClassName(driverClass);
p.setUsername(username);
p.setPassword(passwd);
p.setJmxEnabled(true);
p.setTestWhileIdle(true);
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(200);
p.setInitialSize(10);
p.setMaxWait(10000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(10);
return new org.apache.tomcat.jdbc.pool.DataSource(p);
}
示例3: getTomcatDataSource
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
/**
* Tomcat DataSource 를 빌드합니다.
*
* @param driverClass the driver class
* @param url the url
* @param username the username
* @param passwd the passwd
* @return the tomcat kr.hconnect.data source
*/
protected DataSource getTomcatDataSource(String driverClass, String url, String username, String passwd) {
PoolProperties p = new org.apache.tomcat.jdbc.pool.PoolProperties();
p.setUrl(url);
p.setDriverClassName(driverClass);
p.setUsername(username);
p.setPassword(passwd);
p.setJmxEnabled(true);
p.setTestWhileIdle(true);
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(200);
p.setInitialSize(10);
p.setMaxWait(10000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(10);
return new org.apache.tomcat.jdbc.pool.DataSource(p);
}
示例4: createDatasource
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
protected static javax.sql.DataSource createDatasource(Properties properties) {
PoolProperties p = new PoolProperties();
p.setUrl(properties.getProperty("databaseUrl"));
p.setDriverClassName(properties.getProperty("databaseDriver"));
p.setUsername(properties.getProperty("databaseUser"));
p.setPassword(properties.getProperty("databasePassword"));
p.setJmxEnabled(false);
p.setMaxActive(100);
p.setInitialSize(10);
DataSource datasource = new DataSource();
datasource.setPoolProperties(p);
return datasource;
}
示例5: init
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
private void init(PoolProperties props, boolean enableJmx) throws IOException {
props.setValidationQuery("select 1;");
props.setJmxEnabled(enableJmx);
dataSource.setPoolProperties(props);
try {
dbMigrator.migrate();
} catch (SQLException | IOException e) {
throw new IOException("Database.init() failed", e);
}
}
示例6: getDatabasePoolConfig
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
public DatabasePoolConfig getDatabasePoolConfig(String name) {
DataSourceConfigure configure = DataSourceConfigureLocator.getInstance().getDataSourceConfigure(name);
PoolProperties poolProperties = new PoolProperties();
poolProperties.setTestWhileIdle(configure.getBooleanProperty(TESTWHILEIDLE, DEFAULT_TESTWHILEIDLE));
poolProperties.setTestOnBorrow(configure.getBooleanProperty(TESTONBORROW, DEFAULT_TESTONBORROW));
poolProperties.setTestOnReturn(configure.getBooleanProperty(TESTONRETURN, DEFAULT_TESTONRETURN));
poolProperties.setValidationQuery(configure.getProperty(VALIDATIONQUERY, DEFAULT_VALIDATIONQUERY));
poolProperties.setValidationQueryTimeout(
configure.getIntProperty(VALIDATIONQUERYTIMEOUT, DEFAULT_VALIDATIONQUERYTIMEOUT));
poolProperties.setValidationInterval(configure.getLongProperty(VALIDATIONINTERVAL, DEFAULT_VALIDATIONINTERVAL));
poolProperties.setTimeBetweenEvictionRunsMillis(
configure.getIntProperty(TIMEBETWEENEVICTIONRUNSMILLIS, DEFAULT_TIMEBETWEENEVICTIONRUNSMILLIS));
poolProperties.setMinEvictableIdleTimeMillis(DEFAULT_MINEVICTABLEIDLETIMEMILLIS);
poolProperties.setMaxAge(configure.getIntProperty(MAX_AGE, DEFAULT_MAXAGE));
poolProperties.setMaxActive(configure.getIntProperty(MAXACTIVE, DEFAULT_MAXACTIVE));
poolProperties.setMinIdle(configure.getIntProperty(MINIDLE, DEFAULT_MINIDLE));
poolProperties.setMaxWait(configure.getIntProperty(MAXWAIT, DEFAULT_MAXWAIT));
poolProperties.setInitialSize(configure.getIntProperty(INITIALSIZE, DEFAULT_INITIALSIZE));
poolProperties.setRemoveAbandonedTimeout(
configure.getIntProperty(REMOVEABANDONEDTIMEOUT, DEFAULT_REMOVEABANDONEDTIMEOUT));
poolProperties.setRemoveAbandoned(configure.getBooleanProperty(REMOVEABANDONED, DEFAULT_REMOVEABANDONED));
poolProperties.setLogAbandoned(configure.getBooleanProperty(LOGABANDONED, DEFAULT_LOGABANDONED));
poolProperties
.setConnectionProperties(configure.getProperty(CONNECTIONPROPERTIES, DEFAULT_CONNECTIONPROPERTIES));
poolProperties.setValidatorClassName(configure.getProperty(VALIDATORCLASSNAME, DEFAULT_VALIDATORCLASSNAME));
poolProperties.setJmxEnabled(DEFAULT_JMXENABLED);
poolProperties.setJdbcInterceptors(DEFAULT_JDBCINTERCEPTORS);
return new DatabasePoolConfig(poolProperties);
}
示例7: createDataSource
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
private static DataSource createDataSource(String url, String userName, String password, String driverClass)
throws Exception {
PoolProperties p = new PoolProperties();
p.setUrl(url);
p.setUsername(userName);
p.setPassword(password);
p.setDriverClassName(driverClass);
p.setJmxEnabled(false);
p.setTestWhileIdle(false);
p.setTestOnBorrow(true);
p.setTestOnReturn(false);
p.setValidationQuery("SELECT 1");
p.setValidationQueryTimeout(5);
p.setValidationInterval(30000L);
p.setTimeBetweenEvictionRunsMillis(5000);
p.setMaxActive(100);
p.setMinIdle(0);
p.setMaxWait(10000);
p.setMaxAge(0L);
p.setInitialSize(1);
p.setRemoveAbandonedTimeout(60);
p.setRemoveAbandoned(true);
p.setLogAbandoned(true);
p.setMinEvictableIdleTimeMillis(30000);
p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
org.apache.tomcat.jdbc.pool.DataSource ds = new org.apache.tomcat.jdbc.pool.DataSource(p);
ds.createPool();
return ds;
}
示例8: setUp
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
@Before
public void setUp() {
PoolProperties p = new PoolProperties();
p.setUrl("jdbc:mysql://localhost:3306/mysql");
p.setDriverClassName("com.mysql.jdbc.Driver");
p.setUsername("root");
p.setPassword("");
p.setJmxEnabled(true);
p.setTestWhileIdle(false);
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(100);
p.setInitialSize(10);
p.setMaxWait(10000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(10);
p.setLogAbandoned(true);
p.setRemoveAbandoned(true);
p.setFairQueue(true);
p.setJdbcInterceptors(
"org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" +
"org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
dataSource = new DataSource();
dataSource.setPoolProperties(p);
}
示例9: setUp
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
@Before
public void setUp() {
PoolProperties p = new PoolProperties();
p.setUrl("jdbc:mysql://localhost:3306/admin");
p.setDriverClassName("com.mysql.jdbc.Driver");
p.setUsername("root");
p.setPassword("");
p.setJmxEnabled(true);
p.setTestWhileIdle(false);
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(100);
p.setInitialSize(10);
p.setMaxWait(10000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(10);
p.setLogAbandoned(true);
p.setRemoveAbandoned(true);
p.setFairQueue(true);
p.setJdbcInterceptors(
"org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" +
"org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
dataSource = new DataSource();
dataSource.setPoolProperties(p);
}
示例10: setUp
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
@Before
public void setUp() {
PoolProperties p = new PoolProperties();
p.setUrl("jdbc:mysql://127.0.0.1:3308/admin");
p.setDriverClassName("com.mysql.jdbc.Driver");
p.setUsername("root");
p.setPassword("");
p.setJmxEnabled(true);
p.setTestWhileIdle(false);
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(100);
p.setInitialSize(10);
p.setMaxWait(10000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(10);
p.setLogAbandoned(true);
p.setRemoveAbandoned(true);
p.setFairQueue(true);
p.setJdbcInterceptors(
"org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" +
"org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
dataSource = new DataSource();
dataSource.setPoolProperties(p);
}
示例11: DBConnection
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
public DBConnection(JdbcConfiguration configuration) {
PoolProperties p = new PoolProperties();
p.setDriverClassName(configuration.getDriverClass());
p.setUrl(configuration.getUrl());
p.setUsername(configuration.getUsername());
p.setPassword(configuration.getPassword());
p.setJmxEnabled(true);
p.setTestWhileIdle(false);
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(100);
p.setInitialSize(10);
p.setMaxWait(10000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(10);
p.setLogAbandoned(true);
p.setRemoveAbandoned(true);
p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
this.dataSource = new DataSource();
this.dataSource.setPoolProperties(p);
}
示例12: getInstance
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
/**
* Obtain instance of the SQL Service
*
* @return instance of SQLService
* @throws Exception exception
*/
public static SQLService getInstance() throws Exception {
if (_instance == null) {
_instance = new SQLService();
_instance.startServer();
// default pool size is 20
// can be overriden by env variable
int dbPool = 20;
if (Utils.getEnvironmentOptionValue(Constants.SYS_DATABASE_POOL_SIZE) != null) {
dbPool = Integer.valueOf(Utils.getEnvironmentOptionValue(Constants.SYS_DATABASE_POOL_SIZE));
}
// initialize connection pool
PoolProperties p = new PoolProperties();
String connectString = "jdbc:h2:tcp://" + _instance.databaseHost + ":" + String.valueOf(_instance.port) + "/" +
_instance.databaseName + "/proxydb;MULTI_THREADED=true;AUTO_RECONNECT=TRUE;AUTOCOMMIT=ON";
p.setUrl(connectString);
p.setDriverClassName("org.h2.Driver");
p.setUsername("sa");
p.setJmxEnabled(true);
p.setTestWhileIdle(false);
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(5000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(dbPool);
p.setInitialSize(5);
p.setMaxWait(30000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(10);
p.setLogAbandoned(true);
p.setRemoveAbandoned(true);
_instance.datasource = new DataSource();
_instance.datasource.setPoolProperties(p);
}
return _instance;
}
示例13: getTomcatDataSource
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
/**
* Tomcat DataSource 를 빌드합니다.
*
* @param driverClass DriverClass 명
* @param url Database 주소
* @param username 사용자 명
* @param passwd 사용자 패스워드
* @return [[javax.sql.DataSource]] 인스턴스
*/
public static DataSource getTomcatDataSource(String driverClass, String url, String username, String passwd) {
log.debug("Tomcat DataSource를 빌드합니다... driverClass=[{}], url=[{}], username=[{}], passwd=[{}]",
driverClass, url, username, passwd);
PoolProperties p = new org.apache.tomcat.jdbc.pool.PoolProperties();
p.setUrl(url);
p.setDriverClassName(driverClass);
p.setUsername(username);
p.setPassword(passwd);
p.setJmxEnabled(true);
p.setTestWhileIdle(true);
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(200);
p.setInitialSize(10);
p.setMaxWait(10000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(10);
return new org.apache.tomcat.jdbc.pool.DataSource(p);
}
示例14: initial
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
@Test
public void initial() throws Exception {
PoolProperties p = new PoolProperties();
p.setUrl("jdbc:h2:mem");
p.setDriverClassName("org.h2.Driver");
p.setUsername("sa");
p.setPassword("sa");
p.setJmxEnabled(true);
p.setTestWhileIdle(false);
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(100);
p.setInitialSize(10);
p.setMaxWait(10000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(10);
p.setLogAbandoned(true);
p.setRemoveAbandoned(true);
p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
DataSource dataSource = new DataSource();
dataSource.setPoolProperties(p);
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("select 1")) {
while (resultSet.next()) {
logger.info("{}", resultSet.getObject(1));
}
}
}
示例15: newDataSource
import org.apache.tomcat.jdbc.pool.PoolProperties; //导入方法依赖的package包/类
DataSource newDataSource(HashMapKey hashMapKey, String json) {
TomcatPoolProperties tomcatPoolProperties = new Gson().fromJson(json, TomcatPoolProperties.class);
PoolProperties poolProperties = new PoolProperties();
String username = tomcatPoolProperties.getUsername();
String password = tomcatPoolProperties.getPassword();
String url = tomcatPoolProperties.getUrl();
if (url == null || password == null || username == null) {
throw new MalformedJsonException("The url or username or password is null. Provide " + "proper details.");
}
poolProperties.setUsername(username);
poolProperties.setPassword(password);
poolProperties.setUrl(tomcatPoolProperties.getUrl());
poolProperties.setTestWhileIdle(tomcatPoolProperties.isTestWhileIdle());
poolProperties.setTestOnBorrow(tomcatPoolProperties.isTestOnBorrow());
poolProperties.setTestOnReturn(tomcatPoolProperties.isTestOnReturn());
poolProperties.setValidationQuery(tomcatPoolProperties.getValidationQuery());
poolProperties.setValidationInterval(tomcatPoolProperties.getValidationInterval());
poolProperties.setTimeBetweenEvictionRunsMillis(tomcatPoolProperties.getTimeBetweenEvictionRunsMillis());
poolProperties.setMaxActive(tomcatPoolProperties.getMaxActive());
poolProperties.setMinIdle(tomcatPoolProperties.getMinIdle());
poolProperties.setMaxWait(tomcatPoolProperties.getMaxWait());
poolProperties.setInitialSize(tomcatPoolProperties.getInitialSize());
poolProperties.setRemoveAbandonedTimeout(tomcatPoolProperties.getRemoveAbandonedTimeout());
poolProperties.setRemoveAbandoned(tomcatPoolProperties.isRemoveAbandoned());
poolProperties.setLogAbandoned(tomcatPoolProperties.isLogAbandoned());
poolProperties.setMinEvictableIdleTimeMillis(tomcatPoolProperties.getMinEvictableIdleTimeMillis());
poolProperties.setJmxEnabled(tomcatPoolProperties.isJmxEnabled());
poolProperties.setJdbcInterceptors(tomcatPoolProperties.getJdbcInterceptors());
poolProperties.setDriverClassName(tomcatPoolProperties.getDriverClassName());
boolean forceAlternateUsername = tomcatPoolProperties.isForceAlternateUsername();
if (forceAlternateUsername) {
if (logger.isDebugEnabled()) {
logger.debug("The property forceAlternateUsername is true. Setting it to false(default) improves the " +
"" + "performance while retrieving connections from the pool.");
}
}
javax.sql.DataSource dataSource = new org.apache.tomcat.jdbc.pool.DataSource(poolProperties);
if (logger.isInfoEnabled()) {
logger.info("Successfully prepared the Data Source " + dataSource.getClass() + ". " +
"Registering key for the DataSource provider " + hashMapKey.getDataSourceProvider());
}
((org.apache.tomcat.jdbc.pool.DataSource) dataSource).setAlternateUsernameAllowed(forceAlternateUsername);
if (logger.isInfoEnabled()) {
logger.info("Registering DataSource pool of type TomcatJdbc");
}
this.dataSourcePool.register(hashMapKey, dataSource, json);
return dataSource;
}