question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OracleDataSource created by DataSourceBuilder

See original GitHub issue

Spring boot version: 1.2.3.RELEASE Language: Groovy, 2.4.3 Oracle driver: ojdbc 14

When an Oracle datasource is created it seems to be missing the username.

OracleConnectionPoolDataSource oracleDataSource  = DataSourceBuilder
      .create()
      .type(OracleConnectionPoolDataSource)
      .driverClassName('oracle.jdbc.OracleDriver')
      .url('jdbc:oracle:thin:@localhost:1521:xe')
      .username('repository')
      .password('********')
      .build()


Root cause of that is that calculateMatches method BeanPropertyMatches class is unable to link ‘user’ (which is expected by OracleDataSource) with ‘username’ which is provided by DataSourceBuilder.

Simplest workaround:

private DataSource createNewDataSource(DatasourceConnectionDetails details) {
    OracleConnectionPoolDataSource oracleDataSource  = DataSourceBuilder
      .create()
      .type(OracleConnectionPoolDataSource)
      .driverClassName(details.driverClassName)
      .url(details.url)
      .password(details.password)
      .build()
    oracleDataSource.user = 'repository'
    oracleDataSource
  }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
philwebbcommented, Jun 7, 2016

Looks similar to #1384 and I think we should just be able to change:

new RelaxedDataBinder(result).withAlias("url", "jdbcUrl").bind(properties);

to include withAlias("username", "user").

0reactions
snicollcommented, Jun 9, 2016

Wow, what happened back then?! Thanks for pointing that out @vpavic !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Class DataSourceBuilder<T extends DataSource> - Spring
Convenience class for building a DataSource . Provides a limited subset of the properties supported by a typical DataSource as well as detection...
Read more >
Spring Boot externalised configuration for DataSource not ...
I have tried to remove @ConfigurationProperties and change app.datasource to spring.datasource . I have also tried to use DataSourceBuilder.
Read more >
Data Sources and URLs - Oracle Help Center
Create an OracleDataSource instance, initialize its connection properties as appropriate, and get a connection instance, as in the following example:
Read more >
Oracle Connection Pooling With Spring - Baeldung
For versions prior to 11.2, like Oracle 9i or 10g, we should create an OracleDataSource instead of using Oracle's Universal Connection Pooling.
Read more >
Configuring Spring Boot for Oracle
Oracle Datasource. The easiest approach is to create a configuration bean in the package structure of your Spring Boot application. This will ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found