java - Spring Boot + AWS Linux + Oracle 数据库

标签 java linux spring-boot amazon-ec2 oracle11g

我已经在 AWS Linux 上使用 JPA 开发了 Spring Boot REST API,并以 Oracle11g 作为数据库,因为我们正在处理 Spring boot,所以我们不必处理连接。

netstat -n | grep 1521   

当我触发此命令来检查所有连接是否已关闭时,我可以看到许多连接处于 CLOSE_WAIT 状态。
任何人都可以建议 Tomcat 或 Apache 的应用程序或配置是否有问题吗?

application.properties

spring.datasource.remove-abandoned=true  
spring.datasource.remove-abandoned-timeout=30  
spring.datasource.max-active=50  
spring.datasource.max-idle=8  
spring.datasource.min-idle=8  
spring.datasource.initial-size=10  
spring.datasource.max-wait=10000

最佳答案

问题是 HttpResponse 尚未关闭,为了解决这个问题,我使用了 HttpClientUtils.closeQuietly,请参见下文:

HttpResponse response = null;
    try {
        response = client.execute(createHttpRequest(url, timeOut));
        StringBuilder result = new StringBuilder();
        try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) {
            String line;
            while ((line = rd.readLine()) != null) {
                result.append(line);
            }
        }
        return result;
    } catch (org.apache.http.conn.HttpHostConnectException e) {
        throw new HostUnreachableException(e);
    } finally {
        HttpClientUtils.closeQuietly(response);
    }

关于java - Spring Boot + AWS Linux + Oracle 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53057686/

相关文章:

java - Spymemcached 和连接失败

java - 无法从 Controller 中的请求获取 token

linux - 斜杠和 rsync 命令

java - 终端 - 在后台运行java应用程序以及如何关闭它?

Java G1 GC 处理引用对象运行缓慢

java - 如何将这个程序分成几个类

php - 在 linux mint 32 位操作系统中配置 xampp

带有 Controller 重定向的 Spring MVC 测试发布方法

maven - VsCode 的自动完成功能不适用于新的 spring-boot 项目

java - 在线程中访问 springboot 中的命令行参数