Spring + mySQL 이상한 오류 해결 (Lock wait timeout)

쌍문동두루미·2024년 9월 2일

문제와 해결책

목록 보기
4/6

오류 메시지

### Error updating database. Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
### The error may involve com.miniproj.mappers.pointlogmapper.insertPointlog-Inline
### The error occurred while setting parameters
### SQL: insert into pointlog (pointWho, pointWhy, pointScore) values ( ?, ?, (select pointScore from pointdef where pointWhy = ?) )
### Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
; SQL []; Lock wait timeout exceeded; try restarting transaction; nested exception is com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:259)
"

  • 쿼리를 이상하게 짰다. -> 잘짰음
  • pointlog의 제약조건을 어겼다. -> pointWho가 외래키라서 member 테이블에 있는 값을 삽입해야 함. 문제없음
  • 객체를 통해 쿼리로 넘겨주는 변수의 타입을 잘못 설정하였다. : pointWho, pointWhy, PointScore는 객체에서는 String, String, int으로, DB에서는 VARCHAR, VARCHAR, INT로 설정되어 있음, 따라서 문제 없음
  • mapper.xml의 namespace를 잘못 설정하였다. -> 제대로 설정함
  • 서브쿼리가 문제인 것 같아서 서브쿼리 대신 숫자 넣고 하드코딩함 -> 그래도 안됨
  • pointlogmapper에서 문제가 일어났는데 hboardmapper는 잘됨 -> 똑같은 매퍼 아니야? 뭔 차이임?
  • MySQL Workbench에서 프로세스 죽여봄. -> 그래도 안됨


진짜 뭐임???

해결책

컴퓨터 껐다 키니까 이번엔 새로운 오류가 났었음

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@22fa7c18] was not registered for synchronization because synchronization is not active
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@22fa7c18]
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
### The error may exist in file [D:\lecture\spring\myPractice.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\MiniProject\WEB-INF\classes\mappers\hboardMapper.xml]
### The error may involve com.miniproj.mappers.hboardMapper.getAllBoard

아무것도 안하고 컴퓨터만 재부팅했는데 그전까지 멀쩡하던 hboardMapper에 문제가 생긴거임

그래서 <property name="url" value="jdbc:mysql://localhost:3306/sky?serverTimezone=Asia/Seoul&amp;useSSL=false&amp;allowPublicKeyRetrieval=true"/> 이렇게 allowPublicKeyRetrieval=true 옵션 추가하니까 hboardMapper가 고쳐짐... 그런데 문제는 그동안 문제였던 pointlogmapper도 같이 고쳐짐....

진짜 뭐지??????? 그럼 컴퓨터 껐다 킨게 변수창출한거라고?????? 진짜로???


내 3시간 돌려내

profile
나는 컴퓨터를 좋아함

0개의 댓글