我已经在 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/