Advertisement
Guest User

Untitled

a guest
Nov 13th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. package com.exen.dbroll;
  2.  
  3. import java.sql.SQLException;
  4.  
  5. import javax.sql.DataSource;
  6.  
  7. import org.springframework.beans.factory.annotation.Qualifier;
  8. import org.springframework.context.annotation.Bean;
  9. import org.springframework.context.annotation.Configuration;
  10. import org.springframework.context.annotation.PropertySource;
  11. import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
  12.  
  13. @Configuration
  14. @PropertySource("datasource.properties")
  15. public class AppConfig {
  16.  
  17. @Bean
  18. public static PropertySourcesPlaceholderConfigurer PropertySources() {
  19. return new PropertySourcesPlaceholderConfigurer();
  20. }
  21.  
  22. @Bean
  23. @Qualifier("dataSourceMySQL")
  24. public DataSource dataSourceMySQL() throws SQLException {
  25. CustomDatasource driverManagerDataSource = new CustomDatasource();
  26. driverManagerDataSource.setUrl("jdbc:mysql://localhost/employee");
  27. driverManagerDataSource.setUsername("root");
  28. driverManagerDataSource.setDriverClassName("com.mysql.jdbc.Driver");
  29. return driverManagerDataSource;
  30. }
  31.  
  32. @Bean
  33. @Qualifier("dataSourceOracle")
  34. public DataSource dataSourceOracle() throws SQLException {
  35. CustomDatasource driverManagerDataSource = new CustomDatasource();
  36. driverManagerDataSource.setUrl("jdbc:oracle:thin:@localhost:1521:xe");
  37. driverManagerDataSource.setUsername("system");
  38. driverManagerDataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
  39. return driverManagerDataSource;
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement