8

I was trying to connect to my table and insert some data.We are using oracle database. In the code I have used oracle thin driver ojdbc14.I am getting

2018-12-27 11:08:58.810  INFO 16548 --- [           main] com.zaxxer.hikari.pool.PoolBase          : HikariPool-1 - Driver does not support get/set network timeout for connections. (oracle.jdbc.driver.T4CConnection.getNetworkTimeout()I)
2018-12-27 11:08:58.810 ERROR 16548 --- [           main] com.zaxxer.hikari.pool.PoolBase          : HikariPool-1 - Failed to execute isValid() for connection, configure connection test query (oracle.jdbc.driver.T4CConnection.isValid(I)Z).

I am fairly new to spring boot and was actually trying to

do this demo - https://www.devglan.com/spring-jdbc/working-with-springboot-jdbctemplate

only changes I have done is in my pom.xml and application.properties.

Is there any thing else needed for oracle? How i should solve this?All the example I see for oracle in net is with hibernate.Is is necessary to include hibernate approach? Thank you in advance.


pom.xml

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <dependencies>
        <dependency>
         <groupId>com.oracle</groupId>
            <artifactId>ojdbc14</artifactId>
            <version>10.2.0.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <!-- <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency> -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- HikariCP connection pool -->
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>3.2.0</version>
        </dependency>

    </dependencies>

application.properties

spring.datasource.url=jdbc:oracle:thin:@//url/service
spring.datasource.username=user
spring.datasource.password=password
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
juneSakura
  • 133
  • 1
  • 1
  • 9
  • did you solve it? – Stony Feb 26 '19 at 06:20
  • 1
    ojdbc14.jar is very old. Try switching to ojdbc8.jar from 18.3 (https://www.oracle.com/technetwork/database/application-development/jdbc/downloads/jdbc-ucp-183-5013470.html) that requires JDK8. Also, the connection URL should be as shown. jdbc:oracle:thin:@myhost:1521/myorcldbservicename – Nirmala Feb 28 '19 at 23:28

1 Answers1

8

That is because you are using a very old version of ojdbc. You should be using the latest versions of the Oracle JDBC driver to connect to your Oracle database.

From a quick test here:

sh.seo
  • 1,482
  • 13
  • 20
Arnaud Jeansen
  • 1,619
  • 15
  • 27
  • For those who will face with the sane issue, but working with postgresql: the solution is the same, just update a driver dependency. I was getting the error. Then updated from `org.postgresql:postgresql:42.1.1` to `org.postgresql:postgresql:42.5.1` and it's working fine – HereAndBeyond Jan 05 '23 at 14:21