• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

Database may be already in use: null. 에러 발생 ㅠㅠ

21.05.12 20:21 작성 조회수 9.17k

0

영한님 안녕하세요! 어제 답변주시거 해결하고 다음강의 듣는 중에 또 문제가 생겼습니다 ㅠ_ㅠ 

1. 터미널에서 ./h2.sh 명령어로 실행

2. localhost:8082로 접속 

3. member 테이블생성 

4. 강의를 따라가면서 아래 코드만 작성 후 실행했는데,

EntityManagerFactory emf = Persistence.createEntityManagerFactory("hello");

EntityManager em = emf.createEntityManager();

Member member = new Member();
em.persist(member);

em.close();

emf.close();

강의처럼 

ids for this class must be manullay~ 이 에러가 아닌 아래와 같은 에러가 나타납니다 ㅠㅠ 뭐가 문제일까요?? 

ERROR: Database may be already in use: null. Possible solutions: close all other connection(s); use the server mode [90020-200]

Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

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

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

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

at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)

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

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

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

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

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

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

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

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)

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

Caused by: org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

... 14 more

Caused by: org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database may be already in use: null. Possible solutions: close all other connection(s); use the server mode [90020-200]

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

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

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

at org.h2.mvstore.db.MVTableEngine$Store.convertIllegalStateException(MVTableEngine.java:206)

at org.h2.mvstore.db.MVTableEngine$Store.open(MVTableEngine.java:182)

at org.h2.mvstore.db.MVTableEngine.init(MVTableEngine.java:103)

at org.h2.engine.Database.getPageStore(Database.java:2659)

at org.h2.engine.Database.open(Database.java:675)

at org.h2.engine.Database.openDatabase(Database.java:307)

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

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

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

at org.h2.engine.Engine.createSessionAndValidate(Engine.java:171)

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

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

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

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

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

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

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

... 29 more

Caused by: java.lang.IllegalStateException: The file is locked: nio:/Users/sion/test.mv.db [1.4.200/7]

at org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:950)

at org.h2.mvstore.FileStore.open(FileStore.java:172)

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

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

at org.h2.mvstore.db.MVTableEngine$Store.open(MVTableEngine.java:170)

... 44 more

Process finished with exit code 1


  

답변 4

·

답변을 작성해보세요.

3

안녕하세요. sion007005님

시스템을 재부팅하고

제가 이미지 드린 것과 똑같이 JDBC URL을 입력해주세요^^

jdbc:h2:tcp://localhost/~/test

그럼 정상 동작할거에요.

감사합니다.

2

sion007005님의 프로필

sion007005

질문자

2021.05.15

항상 빠른 답변 주셔서 감사합니다 :)

열공하겠습니다!! 

0

sion007005님의 프로필

sion007005

질문자

2021.05.13

이렇게 나옵니다! ㅠㅠ 

0

안녕하세요. sion007005님

컴퓨터를 재부팅 한 다음에

localhost:8082로 h2 데이터베이스를 띄워서 다음 화면이 저와 같은지 확인해주세요.

특히 JDBC URL부분이 아래와 같은지 확인해주세요.

채널톡 아이콘