Guest User

Untitled

a guest
Nov 8th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. @Component
  2. public class MyDao {
  3. private final Logger log = LoggerFactory.getLogger(MyDao.class);
  4.  
  5. @Autowired
  6. private DataSource dataSource;
  7.  
  8. @Configuration
  9. @ConfigurationProperties("oracle")
  10. public class OracleConfiguration {
  11. @NotNull
  12. private String username;
  13.  
  14. @NotNull
  15. private String password;
  16.  
  17. @NotNull
  18. private String url;
  19.  
  20. public void setUsername(String username) {
  21. this.username = username;
  22. }
  23.  
  24. public void setPassword(String password) {
  25. this.password = password;
  26. }
  27.  
  28. public void setUrl(String url) {
  29. this.url = url;
  30. }
  31.  
  32. @Bean
  33. DataSource dataSource() throws SQLException {
  34.  
  35. OracleDataSource dataSource = new OracleDataSource();
  36. dataSource.setUser(username);
  37. dataSource.setPassword(password);
  38. dataSource.setURL(url);
  39. dataSource.setImplicitCachingEnabled(true);
  40. dataSource.setFastConnectionFailoverEnabled(true);
  41. return dataSource;
  42. }
  43. }
  44.  
  45. #Oracle connection
  46. oracle.username=...
  47. oracle.password=...
  48. oracle.url=jdbc:oracle:thin:@//../..
Add Comment
Please, Sign In to add comment