1

I didn't get a clear picture on making a Oracle JDBC connection in Spring Boot and executing the queries. Can someone please help me or guide me regarding this issue?

1 Answer 1

3

First at all you will need the oracle jdbc driver as maven/gradle dependency. Oracle does not have its driver in the public repository. So you need to download the jdbc driver from oracle and install this jar into a maven dependency.

mvn install:install-file -Dfile=ojdbc7.jar  -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.1 -Dpackaging=jar

Or you can go to the oracle specific maven repository and get the stuff from there.

After that you are able to add this dependency to your pom.xml of your application.

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>12.1.0.1</version>
</dependency>

On the https://start.spring.io/ website you can create a brand new application. For the start I would choose Web and JPA.

Now in the application.properties file you can set your jdbc configurations:

spring.datasource.driverClassName=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:yourUrl
spring.datasource.username=username
spring.datasource.password=password

After that you should be able to start and run the application.

For more you should read docs for Springs repositories, custom queries, custom entity manager

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

3 Comments

How and where should I write the oracle sql queries after the database configuration
@Patrick, Oracle JDBC drivers are available on oracle maven repository. Please refer to this blog (blogs.oracle.com/dev2dev/…) for more details.
@VarunShet please see the provided docs in my answer. There are different easy ways to create sql queries. you should read first the repository stuff

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.