Created
July 21, 2015 09:04
-
-
Save przodownikR1/629f3444d2b3a3399b9a to your computer and use it in GitHub Desktop.
example create datasource in javaConfig with full desc and params
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
public DataSource dataSource() { | |
final DataSource dataSource = new DataSource(); | |
dataSource.setDriverClassName("com.mysql.jdbc.Driver"); | |
dataSource.setUrl(env.getProperty("jdbc.url")); | |
dataSource.setUsername(env.getProperty("jdbc.username")); | |
dataSource.setPassword(env.getProperty("jdbc.password")); | |
dataSource.setTestOnBorrow(true); | |
dataSource.setTestWhileIdle(true); | |
dataSource.setTestOnReturn(false); | |
dataSource.setValidationQuery("SELECT 1"); | |
dataSource.setValidationInterval(30000); | |
dataSource.setTimeBetweenEvictionRunsMillis(5000); | |
dataSource.setMaxActive(100); | |
dataSource.setMinIdle(10); | |
dataSource.setMaxWait(10000); | |
dataSource.setInitialSize(10); | |
dataSource.setRemoveAbandonedTimeout(3600); | |
dataSource.setRemoveAbandoned(true); | |
dataSource.setLogAbandoned(true); | |
dataSource.setMinEvictableIdleTimeMillis(30000); | |
return dataSource; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment