当前位置:网站首页>记录几个常见问题(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.Driver
3.报错: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日
边栏推荐
- Microservice link risk analysis
- opencv 判断点在多边形内外
- Navigation day answer applet: preliminary competition of navigation knowledge competition
- The simple problem of leetcode is to split a string into several groups of length K
- QT creator 7-cmake update
- Decorator learning 01
- Performance monitoring of database tuning solutions
- Nacos installation and service registration
- Win11 runs CMD to prompt the solution of "the requested operation needs to be promoted"
- 如何创建线程
猜你喜欢
IIC bus realizes client device
数博会精彩回顾 | 彰显科研实力,中创算力荣获数字化影响力企业奖
Performance monitoring of database tuning solutions
Overview of concurrency control
[groovy] groovy dynamic language features (automatic type inference of function arguments in groovy | precautions for function dynamic parameters)
Post-90s tester: "after joining Ali, this time, I decided not to change jobs."
装饰器学习01
Distance from point to line intersection and included angle of line
點到直線的距離直線的交點及夾角
Leetcode simple question ring and rod
随机推荐
极狐公司官方澄清声明
Postman核心功能解析-参数化和测试报告
Basic grammar of interview (Part 1)
[groovy] mop meta object protocol and meta programming (Introduction to groovyobject interface | introduction to metaclass | implementation of class methods using groovyobject invokemethod)
Practice: fabric user certificate revocation operation process
The simple problem of leetcode is to split a string into several groups of length K
MySQL actual combat 45 lecture learning (I)
Oracle hint understanding
Sentinel production environment practice (I)
What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method
Three "factions" in the metauniverse
2022-07-05: given an array, you want to query the maximum value in any range at any time. If it is only established according to the initial array and has not been modified in the future, the RMQ meth
database mirroring
Leetcode simple question ring and rod
Talking about MySQL index
Storage optimization of performance tuning methodology
Understand the basic concept of datastore in Android kotlin and why SharedPreferences should be stopped in Android
Business learning of mall order module
科技云报道:算力网络,还需跨越几道坎?
Wonderful review of the digital Expo | highlight scientific research strength, and Zhongchuang computing power won the digital influence enterprise award