Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. package br.edu.foa.loja;
  2.  
  3. import oracle.jdbc.pool.OracleDataSource;
  4. import org.springframework.boot.context.properties.ConfigurationProperties;
  5. import org.springframework.context.annotation.Bean;
  6. import org.springframework.context.annotation.Configuration;
  7. import org.springframework.context.annotation.Profile;
  8. import javax.sql.DataSource;
  9. import javax.validation.constraints.NotNull;
  10. import java.sql.SQLException;
  11. @Configuration
  12. @ConfigurationProperties("oracle")
  13. public class GestorLojaOracleConfiguration {
  14. @NotNull
  15. private String username;
  16. @NotNull
  17. private String password;
  18. @NotNull
  19. private String url;
  20. public void setUsername(String username) {
  21. this.username = username;
  22. }
  23. public void setPassword(String password) {
  24. this.password = password;
  25. }
  26. public void setUrl(String url) {
  27. this.url = url;
  28. }
  29. @Bean
  30. DataSource dataSource() throws SQLException {
  31. OracleDataSource dataSource = new OracleDataSource();
  32. dataSource.setUser(username);
  33. dataSource.setPassword(password);
  34. dataSource.setURL(url);
  35. dataSource.setImplicitCachingEnabled(true);
  36. dataSource.setFastConnectionFailoverEnabled(true);
  37. return dataSource;
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement