by
46 4
0
3
395k
1
Top 1% !
Pearl of Wisdom
Specified
Popularity: 2125th place

Published on:

No tags for this snippet yet.
LanguageJava
SourceGitHub
SourceMyGists

example create datasource in javaConfig with full desc and params

example create datasource in javaConfig with full desc and params: 
db_config_full.java
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1290060/example-create-datasource-in-javaConfig-?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
@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; }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus