我正在使用H2 1.4.191的嵌入式版本,其中包含以下连接字符串:
jdbc:h2:<Path of database file>
我面临两个问题:
有时我的数据库大小超过10GB,系统停止工作。我认为存储在db中的数据不应超过5Mb。消耗内存是什么?
有时候我会遇到这些例外:
org.h2.jdbc.JdbcSQLException:读取记录时文件已损坏:null。可能的解决方案:使用恢复工具[90030-191] 在org.h2.message.DbException.getJdbcSQLException(DbException.java:345) at org.h2.message.DbException.get(DbException.java:168) at org.h2.mvstore.db.MVTableEngine $ Store.convertIllegalStateException(MVTableEngine.java:195) 在org.h2.mvstore.db.MVTableEngine $ Store.open(MVTableEngine.java:167) 在org.h2.mvstore.db.MVTableEngine.init(MVTableEngine.java:99) 在org.h2.engine.Database.getPageStore(Database.java:2460) 在org.h2.engine.Database.open(Database.java:692) 在org.h2.engine.Database.openDatabase(Database.java:270) 在org.h2.engine.Database。(Database.java:264) 在org.h2.engine.Engine.openSession(Engine.java:65) 在org.h2.engine.Engine.openSession(Engine.java:175) at org.h2.engine.Engine.createSessionAndValidate(Engine.java:153) 在org.h2.engine.Engine.createSession(Engine.java:136) at org.h2.engine.Engine.createSession(Engine.java:28) 在org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:349) 在org.h2.jdbc.JdbcConnection。(JdbcConnection.java:107) 在org.h2.jdbc.JdbcConnection。(JdbcConnection.java:91) 在org.h2.Driver.connect(Driver.java:72) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) 在com.j256.ormlite.jdbc.JdbcConnectionSource.makeConnection(JdbcConnectionSource.java:252) 在com.j256.ormlite.jdbc.JdbcConnectionSource.getReadWriteConnection(JdbcConnectionSource.java:184) at com.j256.ormlite.table.TableUtils.doCreateTable(TableUtils.java:440) 在com.j256.ormlite.table.TableUtils.createTable(TableUtils.java:220) at com.j256.ormlite.table.TableUtils.createTableIfNotExists(TableUtils.java:61) 在com.limetray.pos.dbmanagers.DAO.init(DAO.java:75) 在com.limetray.pos.dbmanagers.DAO.createDB(DAO.java:172) 在com.limetray.pos.controllers.MainApp.appInitialization(MainApp.java:91) 在com.limetray.pos.controllers.MainApp.init(MainApp.java:80) at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:841) at com.sun.javafx.application.LauncherImpl.lambda $ launchApplication $ 155(LauncherImpl.java:182) 在java.lang.Thread.run(未知来源) 引起:java.lang.IllegalStateException:块1703中文件损坏,预期检查值1190,得到2040 [1.4.191 / 6] 在org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:773) 在org.h2.mvstore.Page.read(Page.java:667) 在org.h2.mvstore.Page.read(Page.java:195) 在org.h2.mvstore.MVStore.readPage(MVStore.java:1939) 在org.h2.mvstore.MVMap.readPage(MVMap.java:736) 在org.h2.mvstore.Page.getChildPage(Page.java:217) 在org.h2.mvstore.Cursor.min(Cursor.java:129) 在org.h2.mvstore.Cursor.hasNext(Cursor.java:36) 在org.h2.mvstore.MVStore.loadChunkMeta(MVStore.java:689) 在org.h2.mvstore.MVStore.readStoreHeader(MVStore.java:670) 在org.h2.mvstore.MVStore。(MVStore.java:353) 在org.h2.mvstore.MVStore $ Builder.open(MVStore.java:2888) 在org.h2.mvstore.db.MVTableEngine $ Store.open(MVTableEngine.java:154)
和
org.h2.jdbc.JdbcSQLException: General error: "java.lang.NullPointerException" [50000-178]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.convert(DbException.java:294)
at org.h2.engine.Database.openDatabase(Database.java:293)
at org.h2.engine.Database.<init>(Database.java:256)
at org.h2.engine.Engine.openSession(Engine.java:57)
at org.h2.engine.Engine.openSession(Engine.java:164)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:142)
at org.h2.engine.Engine.createSession(Engine.java:125)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:150)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NullPointerException
at org.h2.mvstore.DataUtils.parseMap(DataUtils.java:630)
at org.h2.mvstore.MVStore.openMap(MVStore.java:411)
at org.h2.mvstore.db.TransactionStore.<init>(TransactionStore.java:96)
at org.h2.mvstore.db.MVTableEngine$Store.<init>(MVTableEngine.java:161)
at org.h2.mvstore.db.MVTableEngine.init(MVTableEngine.java:94)
at org.h2.engine.Database.getPageStore(Database.java:2355)
at org.h2.engine.Database.open(Database.java:659)
at org.h2.engine.Database.openDatabase(Database.java:262)
我认为两者都与db腐败问题有关,这在H2中存在。我该如何避免这个问题?如果没有,我可以恢复我的数据吗?