Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Boot/Oracle/Java错误:无法获取JDBC连接结果,导致连接超时_Java_Oracle_Spring Boot_Jdbc - Fatal编程技术网

Spring Boot/Oracle/Java错误:无法获取JDBC连接结果,导致连接超时

Spring Boot/Oracle/Java错误:无法获取JDBC连接结果,导致连接超时,java,oracle,spring-boot,jdbc,Java,Oracle,Spring Boot,Jdbc,我使用的系统具有以下功能(我使用的是Spring Boot) 使用以下命令启动应用程序时出错: Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: `Could not get JDBC Connection`; nested exception is java.sql.SQLRecoverableException: IO Error: `The Network Adapter could not esta

我使用的系统具有以下功能(我使用的是Spring Boot)

使用以下命令启动应用程序时出错:

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: `Could not get JDBC Connection`; nested exception is java.sql.SQLRecoverableException: IO Error: `The Network Adapter could not establish the connection`
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80) ~[spring-jdbc-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:326) ~[spring-jdbc-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    ... 61 common frames omitted
spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/DSV
spring.datasource.username=<my_id>
spring.datasource.password=<my_password>
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery="SELECT 1"

# ===============================
# = JPA / HIBERNATE
# ===============================
# Show or not log for each sql query
spring.jpa.show-sql=true
# Hibernate ddl auto (create, create-drop, update): with "create-drop" the database
# schema will be automatically created afresh for every start of application
spring.jpa.hibernate.ddl-auto=create-drop
# Naming strategy
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
#hibernate config
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
因此,我得到了一个
java.net.ConnectException:Connection timed out:connect

以下是其他信息

为什么我会犯这个错误?代码看到了connection.url,但是它说它不能使用它。据我所知,语法是正确的。我怎样才能解决这个问题

短暂性脑缺血发作

pom.xml文件

    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>ccinrest</groupId>
    <artifactId>BackEndRestFunctionality</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>SpringBootErrorHandlingDemoy</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
    </parent>

    <repositories>
        <repository>
            <id>maven.oracle.com</id>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <url>https://maven.oracle.com</url>
            <layout>default</layout>
        </repository>

    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>maven.oracle.com</id>
            <url>https://maven.oracle.com</url>
        </pluginRepository>
    </pluginRepositories>

    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-ext</artifactId>
            <version>1.7.25</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <!-- <version>5.0.0.RELEASE</version> -->
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            $NO-MVN-MAN-VER$
            <artifactId>spring-security-config</artifactId>
            <!-- <version>5.0.0.RELEASE</version> -->
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <!-- <version>5.0.0.RELEASE</version> -->
        </dependency>

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <!-- <version>1.0.0.RELEASE</version> -->
        </dependency>

        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.8.0</version>
        </dependency>

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc8</artifactId>
            <version>12.2.0.1</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>

        </dependency>
    </dependencies>

</project>
xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
赛因斯特
后端REST功能
0.0.1-快照
罐子
SpringBootErrorHandlingDemoy
http://maven.apache.org
UTF-8
org.springframework.boot
spring启动程序父级
1.5.4.1发布
maven.oracle.com
真的
假的
https://maven.oracle.com
违约
maven.oracle.com
https://maven.oracle.com
org.slf4j
slf4j api
org.slf4j
slf4j分机
1.7.25
javax.servlet
javax.servlet-api
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
spring引导启动器数据jpa
org.springframework.security
spring安全内核
org.springframework.security
$NO-MVN-MAN-VER$
spring安全配置
org.springframework.security
spring安全网
org.springframework.data
spring数据jpa
io.jsonwebtoken
jjwt
0.8.0
com.oracle
ojdbc8
12.2.0.1
org.hibernate
休眠实体管理器
org.hibernate
休眠验证器
application.properties文件如下所示:

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: `Could not get JDBC Connection`; nested exception is java.sql.SQLRecoverableException: IO Error: `The Network Adapter could not establish the connection`
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80) ~[spring-jdbc-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:326) ~[spring-jdbc-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    ... 61 common frames omitted
spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/DSV
spring.datasource.username=<my_id>
spring.datasource.password=<my_password>
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery="SELECT 1"

# ===============================
# = JPA / HIBERNATE
# ===============================
# Show or not log for each sql query
spring.jpa.show-sql=true
# Hibernate ddl auto (create, create-drop, update): with "create-drop" the database
# schema will be automatically created afresh for every start of application
spring.jpa.hibernate.ddl-auto=create-drop
# Naming strategy
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
#hibernate config
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/DSV
spring.datasource.username=
spring.datasource.password=
spring.datasource.driver类名=oracle.jdbc.OracleDriver
#如果长时间处于空闲状态(生产中需要),请保持连接处于活动状态
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=“选择1”
# ===============================
#=JPA/HIBERNATE
# ===============================
#显示或不显示每个sql查询的日志
spring.jpa.show sql=true
#HibernateDDL自动(创建、创建删除、更新):使用“创建删除”数据库
#每次启动应用程序时,将自动重新创建架构
spring.jpa.hibernate.ddl auto=createdrop
#命名策略
spring.jpa.hibernate.naming.implicit strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
spring.jpa.hibernate.naming.physical strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
#允许Hibernate生成针对特定DBMS优化的SQL
spring.jpa.properties.hibernate.dialogue=org.hibernate.dialogue.Oracle10gDialogue
#休眠配置
spring.jpa.database platform=org.hibernate.dialen.oracle10galent
错误日志

.   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.4.RELEASE)

2018-01-24 19:25:06.507  INFO 12076 --- [           main] ccinrest.App                             : Starting App on DESKTOP-8EFRPQF with PID 12076 (C:\WORK\Test\SpringBootErrorHandlingDemo\target\classes started by dgmufasa in C:\WORK\Test\SpringBootErrorHandlingDemo)
2018-01-24 19:25:06.511  INFO 12076 --- [           main] ccinrest.App                             : No active profile set, falling back to default profiles: default
2018-01-24 19:25:06.629  INFO 12076 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@64d7f7e0: startup date [Wed Jan 24 19:25:06 CST 2018]; root of context hierarchy
2018-01-24 19:25:09.949  INFO 12076 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-01-24 19:25:09.968  INFO 12076 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-01-24 19:25:09.973  INFO 12076 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.15
2018-01-24 19:25:10.183  INFO 12076 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-01-24 19:25:10.183  INFO 12076 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3559 ms
2018-01-24 19:25:10.523  INFO 12076 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-01-24 19:25:10.524  INFO 12076 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-01-24 19:25:10.524  INFO 12076 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-01-24 19:25:10.524  INFO 12076 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-01-24 19:25:10.526  INFO 12076 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-01-24 19:25:10.526  INFO 12076 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2018-01-24 19:25:33.725 ERROR 12076 --- [           main] o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.

java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:774) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
    at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:688) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:39) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:691) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310) ~[tomcat-jdbc-8.5.15.jar:na]
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.15.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:735) [tomcat-jdbc-8.5.15.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:667) [tomcat-jdbc-8.5.15.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:482) [tomcat-jdbc-8.5.15.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154) [tomcat-jdbc-8.5.15.jar:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118) [tomcat-jdbc-8.5.15.jar:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107) [tomcat-jdbc-8.5.15.jar:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131) [tomcat-jdbc-8.5.15.jar:na]
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) [spring-jdbc-4.3.9.RELEASE.jar:4.3.9.RELEASE]

[.. snip ...]

Caused by: java.net.ConnectException: Connection timed out: connect
    at sun.nio.ch.Net.connect0(Native Method) ~[na:1.8.0_161]
    at sun.nio.ch.Net.connect(Unknown Source) ~[na:1.8.0_161]
    at sun.nio.ch.Net.connect(Unknown Source) ~[na:1.8.0_161]
    at sun.nio.ch.SocketChannelImpl.connect(Unknown Source) ~[na:1.8.0_161]
    at java.nio.channels.SocketChannel.open(Unknown Source) ~[na:1.8.0_161]
    at oracle.net.nt.TimeoutSocketChannel.<init>(TimeoutSocketChannel.java:81) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
    at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:169) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
    ... 57 common frames omitted
。\uuuuuuuuuuuu_
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
'  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
::弹簧靴::(v1.5.4.版本)
2018-01-24 19:25:06.507 INFO 12076---[main]ccinrest.App:在桌面上启动应用程序-8EFRPQF,PID 12076(C:\WORK\Test\SpringBootErrorHandlingDemo\target\classes由dgmufasa在C:\WORK\Test\SpringBootErrorHandlingDemo中启动)
2018-01-24 19:25:06.511信息12076---[main]ccinrest.App:未设置活动配置文件,返回默认配置文件:默认
2018-01-24 19:25:06.629信息12076---[main]国家配置嵌入式Web应用程序上下文:刷新org.springframework.boot.context.embedded。AnnotationConfigEmbeddedWebApplicationContext@64d7f7e0:启动日期[Wed Jan 24 19:25:06 CST 2018];上下文层次结构的根
2018-01-24 19:25:09.949信息12076---[main]s.b.c.e.t.TomcatEmbeddedServletContainer:Tomcat已用端口初始化:8080(http)
2018-01-24 19:25:09.968信息12076---[main]o.apache.catalina.core.StandardService:启动服务[Tomcat]
2018-01-24 19:25:09.973信息12076---[main]org.apache.catalina.core.StandardEngine:启动Servlet引擎:apache Tomcat/8.5.15
2018-01-24 19:25:10.183信息12076---[ost-startStop-1]o.a.c.c.c.[Tomcat].[localhost].[/]:初始化Spring嵌入式WebApplicationContext
2018-01-24 19:25:10.183信息12076---[ost-startStop-1]o.s.web.context.ContextLoader:根WebApplicationContext:初始化在3559毫秒内完成
2018-01-24 19:25:10.523信息12076---[ost-startStop-1]o.s.b.w.servlet.FilterRegistrationBean:将筛选器:“characterEncodingFilter”映射到:[/*]
2018-01-24 19:25:10.524信息12076---[ost-startStop-1]o.s.b.w.servlet.FilterRegistrationBean:将筛选器:“hiddenHttpMethodFilter”映射到:[/*]
2018-01-24 19:25:10.524信息12076---[ost-startStop-1]o.s.b.w.servlet.FilterRegistrationBean:将筛选器:“httpPutFormContentFilter”映射到:[/*]
2018-01-24 19