【问题标题】:How to fix "Driver does not support get/set network timeout for connections" while connecting to oracle database from spring boot app?从 Spring Boot 应用程序连接到 Oracle 数据库时,如何解决“驱动程序不支持获取/设置连接的网络超时”?
【发布时间】:2019-05-25 04:54:05
【问题描述】:

我试图连接到我的表并插入一些数据。我们正在使用 oracle 数据库。 在我使用oracle瘦驱动程序ojdbc14的代码中。我得到了

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).

我对 Spring Boot 还很陌生,实际上正在尝试

做 这个演示 - https://www.devglan.com/spring-jdbc/working-with-springboot-jdbctemplate

我所做的唯一更改是在我的 pom.xml 和 application.properties 中。

oracle 还有其他需要的吗?我应该如何解决这个问题?我在网上看到的所有 Oracle 示例都是使用休眠的。是否有必要包含休眠方法? 提前谢谢你。


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

【问题讨论】:

标签: java spring oracle spring-boot hikaricp


【解决方案1】:

那是因为您使用的是非常旧的 ojdbc 版本。 您应该使用最新版本的 Oracle JDBC 驱动程序连接到您的 Oracle 数据库。

这里的快速测试:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-22
    • 1970-01-01
    • 1970-01-01
    • 2017-10-16
    • 1970-01-01
    • 2018-05-12
    • 2019-08-25
    相关资源
    最近更新 更多