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

작성자 없음

작성자 정보가 삭제된 글입니다.

자바 ORM 표준 JPA 프로그래밍 - 기본편

2024 최신 버전으로 프로젝트 설정하기 - 소스코드

세팅부터 안되고있네요.....

작성

·

89

0

 

 

9월 01, 2024 7:00:54 오전 org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator getJdbcEnvironmentUsingJdbcMetadata

WARN: HHH000342: Could not obtain connection to query metadata

java.lang.IllegalStateException: Cannot get a connection as the driver manager is not properly initialized

at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:259)

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:428)

at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.delegateWork(JdbcIsolationDelegate.java:61)

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:276)

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:107)

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68)

at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:130)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)

at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:52)

at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:136)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:247)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)

at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:132)

at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:43)

at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:61)

at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.addConnections(DriverManagerConnectionProviderImpl.java:499)

at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.<init>(DriverManagerConnectionProviderImpl.java:372)

at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections$Builder.build(DriverManagerConnectionProviderImpl.java:550)

at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:102)

at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:82)

at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:136)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:247)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:395)

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:262)

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:107)

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68)

at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:130)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)

at org.hibernate.boot.model.relational.Database.<init>(Database.java:45)

at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:223)

at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:191)

at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:170)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1432)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1503)

at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:55)

at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)

at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)

at hellojpa.JpaMain.main(JpaMain.java:9)

9월 01, 2024 7:00:54 오전 org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl constructDialect

WARN: HHH90000025: H2Dialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)

9월 01, 2024 7:00:54 오전 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions

WARN: SQL Error: 90048, SQLState: 90048

9월 01, 2024 7:00:54 오전 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions

ERROR: Unsupported database file version or invalid file header in file "C:/Users/user/test.mv.db" [90048-224]

Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Error calling Driver#connect [Unsupported database file version or invalid file header in file "C:/Users/user/test.mv.db" [90048-224]] [null]

at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:276)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)

at org.hibernate.boot.model.relational.Database.<init>(Database.java:45)

at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:223)

at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:191)

at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:170)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1432)

at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1503)

at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:55)

at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)

at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)

at hellojpa.JpaMain.main(JpaMain.java:9)

Caused by: org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect [Unsupported database file version or invalid file header in file "C:/Users/user/test.mv.db" [90048-224]] [null]

at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:51)

at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:58)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:108)

at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:134)

at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:43)

at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:61)

at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.addConnections(DriverManagerConnectionProviderImpl.java:499)

at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.<init>(DriverManagerConnectionProviderImpl.java:372)

at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections$Builder.build(DriverManagerConnectionProviderImpl.java:550)

at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:102)

at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:82)

at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:136)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:247)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215)

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:395)

at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:262)


이런식으로 오류가뜨는데 뭐가 문제인지 모르겟네요. 세팅부터 문제가 생겼는데 해결이안돼 공부를 할수가 없어 너무 답답합니다.

 

답변 1

0

안녕하세요, 인프런 AI 인턴입니다.

옥자님의 문제는 JPA 설정과 관련된 오류로 인해 데이터베이스 연결이 실패하는 경우로 보입니다. 구체적으로, java.lang.IllegalStateException: Cannot get a connection as the driver manager is not properly initializedUnsupported database file version or invalid file header in file 오류가 나타나며, H2 데이터베이스 파일(.mv.db)에 문제가 있거나, 데이터베이스 드라이버가 제대로 초기화되지 않았을 가능성이 있습니다.

해결 방법 요약:

  1. H2 데이터베이스 버전 확인: 사용 중인 H2 데이터베이스의 버전이 최신인지 확인하고, 필요한 경우 업데이트하세요. 때때로 버전 불일치가 문제를 일으킬 수 있습니다.

  2. 데이터베이스 파일 검사: 오류 로그에서 언급된 .mv.db 파일이 올바른 위치에 있고, 손상되지 않았는지 검사하세요. 잘못된 파일 헤더나 지원되지 않는 파일 버전 오류는 파일이 손상되었거나 호환되지 않는 버전으로 생성되었을 때 발생할 수 있습니다.

  3. 연결 설정 검증: persistence.xml 또는 Spring Boot의 application.properties / application.yml에서 데이터베이스 연결 설정이 올바르게 구성되었는지 확인하세요. 특히, JDBC URL, 사용자 이름, 비밀번호가 정확한지 다시 한번 검토합니다.

  4. 하이버네이트 설정: 오류 로그에 따르면, H2Dialect를 명시적으로 지정할 필요가 없습니다. 하이버네이트가 자동으로 인식할 수 있도록 설정에서 해당 속성을 제거하세요.

이와 유사한 문제를 겪고 계신 다른 학습자들을 위해 몇 가지 관련 질문 링크를 추천해드립니다:

특히, 데이터베이스 파일 버전 불일치나 JDBC 드라이버가 제대로 초기화되지 않는 문제는 종종 잘못된 데이터베이스 버전 사용이나 프로젝트 세팅 누락으로 인해 발생할 수 있습니다. 위의 링크에서 유사한 문제에 대한 해결 방안을 찾으시길 바랍니다.

저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다.
현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏
추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.

작성자 없음

작성자 정보가 삭제된 글입니다.

질문하기