Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Component
- public class MyDao {
- private final Logger log = LoggerFactory.getLogger(MyDao.class);
- @Autowired
- private DataSource dataSource;
- @Configuration
- @ConfigurationProperties("oracle")
- public class OracleConfiguration {
- @NotNull
- private String username;
- @NotNull
- private String password;
- @NotNull
- private String url;
- public void setUsername(String username) {
- this.username = username;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public void setUrl(String url) {
- this.url = url;
- }
- @Bean
- DataSource dataSource() throws SQLException {
- OracleDataSource dataSource = new OracleDataSource();
- dataSource.setUser(username);
- dataSource.setPassword(password);
- dataSource.setURL(url);
- dataSource.setImplicitCachingEnabled(true);
- dataSource.setFastConnectionFailoverEnabled(true);
- return dataSource;
- }
- }
- #Oracle connection
- oracle.username=...
- oracle.password=...
- oracle.url=jdbc:oracle:thin:@//../..
Add Comment
Please, Sign In to add comment