인프런 커뮤니티 질문&답변

9rrrr_m님의 프로필 이미지

작성한 질문수

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

스프링 통합 테스트

MemberServiceIntegrationTest 시 Failed to obtain JDBC Connection 오류

작성

·

287

0

[질문 템플릿]
1. 강의 내용과 관련된 질문인가요? (예)
2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)
3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)

[질문 내용]

오류.PNG다른 오류들은 차근차근 해결했는데 h2도 정상 작동하고 다른 코드들도 다 확인하고 소스 코드 복붙도 해보고(오타 방지) 했으나 다음과 같이 오류가 발생합니다. 이 테스트 말고는 다 정상적으로 테스트가 돌아가는데 DB랑 연결이 안되는건지 문의드립니다.


java.lang.IllegalStateException: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection

at rrrrm._rrrr_m.repository.JdbcMemberRepository.findByName(JdbcMemberRepository.java:107)

at rrrrm._rrrr_m.service.MemberService.validateDuplicateMember(MemberService.java:31)

at rrrrm._rrrr_m.service.MemberService.join(MemberService.java:25)

at rrrrm._rrrr_m.service.MemberServiceIntegrationTest.중복_회원_예외(MemberServiceIntegrationTest.java:46)

at java.base/java.lang.reflect.Method.invoke(Method.java:568)

at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection

at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:84)

at rrrrm._rrrr_m.repository.JdbcMemberRepository.getConnection(JdbcMemberRepository.java:113)

at rrrrm._rrrr_m.repository.JdbcMemberRepository.findByName(JdbcMemberRepository.java:95)

... 6 more

Caused by: org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database may be already in use: "C:/Users/computer/test.mv.db". Possible solutions: close all other connection(s); use the server mode [90020-224]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:690)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)

at org.h2.message.DbException.get(DbException.java:212)

at org.h2.mvstore.db.Store.convertMVStoreException(Store.java:165)

at org.h2.mvstore.db.Store.<init>(Store.java:142)

at org.h2.engine.Database.<init>(Database.java:326)

at org.h2.engine.Engine.openSession(Engine.java:92)

at org.h2.engine.Engine.openSession(Engine.java:222)

at org.h2.engine.Engine.createSession(Engine.java:201)

at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343)

at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:125)

at org.h2.Driver.connect(Driver.java:59)

at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:137)

at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:360)

at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202)

at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:461)

at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:550)

at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:98)

at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:111)

at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:160)

at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:118)

at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81)

... 8 more

Caused by: org.h2.mvstore.MVStoreException: The file is locked: C:/Users/computer/test.mv.db [2.2.224/7]

at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)

at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143)

at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117)

at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81)

at org.h2.mvstore.MVStore.<init>(MVStore.java:286)

at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)

at org.h2.mvstore.db.Store.<init>(Store.java:133)

... 25 more

2024-06-14T23:13:01.731+09:00 INFO 18164 --- [9rrrr_m] [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...

java.lang.IllegalStateException: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection

at rrrrm._rrrr_m.repository.JdbcMemberRepository.findByName(JdbcMemberRepository.java:107)

at rrrrm._rrrr_m.service.MemberService.validateDuplicateMember(MemberService.java:31)

at rrrrm._rrrr_m.service.MemberService.join(MemberService.java:25)

at rrrrm._rrrr_m.service.MemberServiceIntegrationTest.회원가입(MemberServiceIntegrationTest.java:29)

at java.base/java.lang.reflect.Method.invoke(Method.java:568)

at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection

at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:84)

at rrrrm._rrrr_m.repository.JdbcMemberRepository.getConnection(JdbcMemberRepository.java:113)

at rrrrm._rrrr_m.repository.JdbcMemberRepository.findByName(JdbcMemberRepository.java:95)

... 6 more

Caused by: org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database may be already in use: "C:/Users/computer/test.mv.db". Possible solutions: close all other connection(s); use the server mode [90020-224]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:690)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)

at org.h2.message.DbException.get(DbException.java:212)

at org.h2.mvstore.db.Store.convertMVStoreException(Store.java:165)

at org.h2.mvstore.db.Store.<init>(Store.java:142)

at org.h2.engine.Database.<init>(Database.java:326)

at org.h2.engine.Engine.openSession(Engine.java:92)

at org.h2.engine.Engine.openSession(Engine.java:222)

at org.h2.engine.Engine.createSession(Engine.java:201)

at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:343)

at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:125)

at org.h2.Driver.connect(Driver.java:59)

at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:137)

at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:360)

at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202)

at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:461)

at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:550)

at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:98)

at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:111)

at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:160)

at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:118)

at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81)

... 8 more

Caused by: org.h2.mvstore.MVStoreException: The file is locked: C:/Users/computer/test.mv.db [2.2.224/7]

at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)

at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143)

at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117)

at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81)

at org.h2.mvstore.MVStore.<init>(MVStore.java:286)

at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)

at org.h2.mvstore.db.Store.<init>(Store.java:133)

... 25 more

Process finished with exit code -1

답변 1

0

안녕하세요. 9rrrr_m님, 공식 서포터즈 OMG입니다.

메시지 내용으로 봐서는 h2가 단일로 실행되어야 하는데, 백그라운드에서 중복으로 실행되고 있는 상황으로 예상이 됩니다.

PC를 재부팅하고 확인해보시겠어요?

해결이 안될 경우 아래 링크의 영한님 답변을 참고하여 h2 실행 화면을 캡쳐로 남겨주세요.

+추가로 application.properties도 화면을 캡쳐하여 올려주세요

 

https://www.inflearn.com/questions/211951/database-may-be-already-in-use-null-%EC%97%90%EB%9F%AC-%EB%B0%9C%EC%83%9D-%E3%85%A0%E3%85%A0

감사합니다.

9rrrr_m님의 프로필 이미지

작성한 질문수

질문하기