当前位置:网站首页>记录几个常见问题(202207)
记录几个常见问题(202207)
2022-07-05 22:23:00 【zhangbeizhen18】
记录:282
场景:几个常见问题:
Java代码执行SQL语句导致线程卡住,不往下执行了。
CLIENT_PUGIN_AUTH is required。
Communications link failure。
java.lang.ClassNotFoundException。
版本:Spring Boot 2.6.3
一、案例场景
1.Java代码执行SQL语句导致线程卡住,不往下执行了
问题:Java线程池的10个线程,并发在Oracle数据库的表T_DEMO的执行UPDATE语句。但是10个线程都卡住了,导致任务堆积了,而且try catch都没有捕获异常。
原因:Oracle数据库的表T_DEMO,在PL/SQL客户端对全表执行了FOR UPDATE锁住表,没有提交。导致Java代码在执行UPDATE语句时,获取不到数据库表操作,一直在等待。且没有抛出异常。
解决:在数据源类中设置超时时间,例如。
DruidDataSource dataSource = new DruidDataSource();
dataSource.setQueryTimeout(60);现象:超时,会抛出异常。
Caused by: java.sql.SQLTimeoutException: ORA-01013: 用户请求取消当前的操作
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:630)
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:564)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1151)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:771)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:299)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:498)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:152)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1052)
at oracle.jdbc.driver.OracleStatement.executeSQLStatement(OracleStatement.java:1531)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1311)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3746)
at oracle.jdbc.driver.OraclePreparedStatement.executeLargeUpdate(OraclePreparedStatement.java:3918)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3897)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:992)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeUpdate(DruidPooledPreparedStatement.java:255)
at org.springframework.jdbc.core.JdbcTemplate.lambda$update$2(JdbcTemplate.java:965)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:651)
... 9 more
Caused by: Error : 1013, Position : 0,......2.报错:CLIENT_PUGIN_AUTH is required
报错:java.sql.SQLNontransientConnectionException: CLIENT_PUGIN_AUTH is required
原因:本例的MySQL数据库版本是5.6.29,而在pom.xml中引入了8.0.23驱动
解决:MySQL驱动降低版本。
2.1 pom.xml变更
高版本:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>>8.0.23</version>
</dependency>变更为:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
</dependency>2.2 application.yml变更
MySQL驱动类:
高版本:
com.mysql.cj.jdbc.Driver变更为:
com.mysql.jdbc.Driver3.报错:404 Not Found: [no body]
报错:
org.springframework.web.client.HttpClientErrorException$NotFound: 404 Not Found: [no body]
at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:113)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:168)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:122)
at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63)
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:819)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:777)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711)
at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:437)解决:本例是访问的服务端Controller的方法变了,重新确定服务端访问路径。
4.报错:Communications link failure
报错:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure.
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.解决:数据库连接信息不对。
5.报错:ClassNotFoundException
报错:
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpSessionIdListener原因:
基于Spring Boot 2.6.3的web工程:
在Tomcat 7的servlet-api.java中没有HttpSessionIdListener。
在Tomcat 8的javax.servlet-api-4.0.1.jar中有HttpSessionIdListener。
解决:war包部署环境变更为Tomcat 8。
以上,感谢。
2022年7月4日
边栏推荐
- Server optimization of performance tuning methodology
- Unique occurrence times of leetcode simple questions
- Interview questions for famous enterprises: Coins represent a given value
- 解决thinkphp启动时“No input file specified”的问题
- Search: Future Vision (moving sword)
- 笔记本电脑蓝牙怎么用来连接耳机
- The statistics of leetcode simple question is the public string that has appeared once
- 50. Pow(x, n). O(logN) Sol
- Livelocks and deadlocks of concurrency control
- "Chris Richardson microservices series" uses API gateway to build microservices
猜你喜欢

Leetcode simple question ring and rod

Decorator learning 01

50. Pow(x, n). O(logN) Sol

Search: Future Vision (moving sword)

The simple problem of leetcode is to split a string into several groups of length K

MySQL actual combat 45 lecture learning (I)

Promql demo service

实战:fabric 用户证书吊销操作流程

2022-07-05:给定一个数组,想随时查询任何范围上的最大值。 如果只是根据初始数组建立、并且以后没有修改, 那么RMQ方法比线段树方法好实现,时间复杂度O(N*logN),额外空间复杂度O(N*

Win11 runs CMD to prompt the solution of "the requested operation needs to be promoted"
随机推荐
Talking about MySQL index
Decorator learning 01
Calculation method of boundary IOU
Depth first DFS and breadth first BFS -- traversing adjacency tables
Index optimization of performance tuning methodology
数博会精彩回顾 | 彰显科研实力,中创算力荣获数字化影响力企业奖
Sentinel production environment practice (I)
Promql demo service
2022 Software Test Engineer salary increase strategy, how to reach 30K in three years
Summary of concurrency control
Serializability of concurrent scheduling
微服务链路风险分析
[error record] file search strategy in groovy project (src/main/groovy/script.groovy needs to be used in the main function | groovy script directly uses the relative path of code)
Business learning of mall order module
Oracle advanced query
等到产业互联网时代真正发展成熟,我们将会看待一系列的新产业巨头的出现
Navigation day answer applet: preliminary competition of navigation knowledge competition
Storage optimization of performance tuning methodology
Text组件新增内容通过tag_config设置前景色、背景色
Blocking of concurrency control