当前位置:网站首页>Record several frequently asked questions (202207)

Record several frequently asked questions (202207)

2022-07-05 22:25:00 zhangbeizhen18

Record :282

scene : Several common questions :

Java Code execution SQL Statement causes the thread to get stuck , No more execution .

CLIENT_PUGIN_AUTH is required.

Communications link failure.

java.lang.ClassNotFoundException.

edition :Spring Boot 2.6.3

One 、 Case scenario

1.Java Code execution SQL Statement causes the thread to get stuck , No more execution

problem :Java Thread pool 10 Threads , Concurrent in Oracle Table of database T_DEMO Implementation UPDATE sentence . however 10 All threads are stuck , This leads to the accumulation of tasks , and try catch No exceptions were caught .

reason :Oracle Table of database T_DEMO, stay PL/SQL The client executes on the whole table FOR UPDATE Lock the watch , Not submit . Lead to Java The code is executing UPDATE When the sentence is , Cannot get database table operation , Been waiting . And no exception is thrown .

solve : Set the timeout in the data source class , for example .

DruidDataSource dataSource = new DruidDataSource();
dataSource.setQueryTimeout(60);

The phenomenon : Overtime , It throws an exception .

Caused by: java.sql.SQLTimeoutException: ORA-01013:  The user requested to cancel the current operation 
  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. Report errors :CLIENT_PUGIN_AUTH is required

Report errors :java.sql.SQLNontransientConnectionException: CLIENT_PUGIN_AUTH is required

reason : In this case MySQL The database version is 5.6.29, And in the pom.xml Introduced in 8.0.23 drive

solve :MySQL Drive reduced version .

2.1 pom.xml change

Higher version

<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>>8.0.23</version>
</dependency>

Changed to:

<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>5.1.49</version>
</dependency>

2.2 application.yml change

MySQL Drive class :

Higher version

com.mysql.cj.jdbc.Driver

Changed to:

com.mysql.jdbc.Driver

3. Report errors :404 Not Found: [no body]

Report errors

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)

solve : This example is the server of access Controller The way of doing this has changed , Re determine the server access path .

4. Report errors :Communications link failure

Report errors

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.

solve : The database connection information is incorrect .

5. Report errors :ClassNotFoundException

Report errors

Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpSessionIdListener

reason

be based on Spring Boot 2.6.3 Of web engineering :

stay Tomcat 7 Of servlet-api.java There is no HttpSessionIdListener.

stay Tomcat 8 Of javax.servlet-api-4.0.1.jar There is HttpSessionIdListener.

solve :war The package deployment environment is changed to Tomcat 8.

above , thank .

2022 year 7 month 4 Japan

原网站

版权声明
本文为[zhangbeizhen18]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207052223013974.html