Guest User

Untitled

a guest
Apr 14th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. In my spring boot application while trying to connect to the oracle database i get the following exception
  2.  
  3. java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
  4. at oracle.jdbc.pool.OracleDataSource.makeURL(OracleDataSource.java:1536)
  5. at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:214)
  6. at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:184)
  7. at com.pravaa.apex.MainController.getEmployees(MainController.java:22)
  8. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  9. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  10.  
  11. #Oracle connection
  12. oracle.username=a_test_erd
  13. oracle.password=somepassword
  14. oracle.url=jdbc:oracle:thin:@abc.def.com:1521:XE
  15.  
  16. import java.sql.SQLException;
  17.  
  18. import javax.sql.DataSource;
  19. import javax.validation.constraints.NotNull;
  20.  
  21. import org.springframework.boot.context.properties.ConfigurationProperties;
  22. import org.springframework.context.annotation.Bean;
  23. import org.springframework.context.annotation.Configuration;
  24.  
  25. import oracle.jdbc.pool.OracleDataSource;
  26.  
  27. @Configuration
  28. @ConfigurationProperties("oracle")
  29. public class OracleConfiguration {
  30. @NotNull
  31. private String username;
  32.  
  33. @NotNull
  34. private String password;
  35.  
  36. @NotNull
  37. private String url;
  38.  
  39. public void setUsername(String username) {
  40. this.username = username;
  41. }
  42.  
  43. public void setPassword(String password) {
  44. this.password = password;
  45. }
  46.  
  47. public void setUrl(String url) {
  48. this.url = url;
  49. }
  50.  
  51. @Bean
  52. DataSource dataSource() throws SQLException {
  53. OracleDataSource dataSource = new OracleDataSource();
  54. dataSource.setUser(username);
  55. dataSource.setPassword(password);
  56. dataSource.setURL(url);
  57. dataSource.setImplicitCachingEnabled(true);
  58. dataSource.setFastConnectionFailoverEnabled(true);
  59. return dataSource;
  60. }
  61. }
Add Comment
Please, Sign In to add comment