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?

dur
  • 15,689
  • 25
  • 79
  • 125
Varun Shet
  • 21
  • 2

1 Answers1

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

Community
  • 1
  • 1
Patrick
  • 12,336
  • 15
  • 73
  • 115
  • How and where should I write the oracle sql queries after the database configuration – Varun Shet May 16 '17 at 07:28
  • @Patrick, Oracle JDBC drivers are available on oracle maven repository. Please refer to this blog (https://blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides) for more details. – Nirmala May 16 '17 at 22:29
  • @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 – Patrick May 17 '17 at 05:43