3

The spring boot application by default is connecting to derby embedded database as shown in the below statement.

Starting embedded database: url='jdbc:derby:memory:testdb;create=true', username='sa'

I don't know where it is picking the above url from

I need to connect weblogic oracle datasource I gave the following properties in the application.properties of the application but its not picking the below properties

spring.jpa.hibernate.ddl-auto=create-drop

# Oracle settings
spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/XE
spring.datasource.username=system
spring.datasource.password=vasu
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver

Added the following entry in pom.xml

<dependency>
    <groupId>com.github.noraui</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>12.1.0.2</version>
</dependency>   
1
  • I am co-creator of com.github.noraui, this jar file is deprecated, please use this sample: github.com/sgrillon14/MavenSampleOracleJdbc Commented Oct 4, 2018 at 9:44

1 Answer 1

8

I assume you already have your oracle datasource defined in the weblogic, so you don't need neither oracle driver in your application classpath nor spring.datasource.{url,username,password,driver-class-name} properties defined.

What you need instead is spring.datasource.jndi-name property. Just set it to jndi name of your datasource from weblogic and spring will pickup it just like that.

Of course you have to have an oracle driver in weblogic classpath (lib directory or something like that).

spring.datasource.jndi-name=java:jdbc/OracleDS

Documentation.

Sign up to request clarification or add additional context in comments.

4 Comments

Hi. Do you know how can I do if the webapp is not in the localhost?. Something like this: "spring.datasource.jndi-name: t3//192.151.110.180:7001/jdbc/conEsos"
@J.Abel did you able to find answer to your question?
Yes I can get it, however I can not do it from the application.config file. I did it from a @Configuration class.
@J.Abel I am trying to figureout that one as well but couldn't find the solution yet. Can you give me some hint?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.