我在具有以下连接字符串的Windows计算机上使用H2 1.3.172:
jdbc:h2:tcp://localhost/dev/*****;LOG=0;UNDO_LOG=0;DB_CLOSE_ON_EXIT=TRUE;IGNORECASE=TRUE;OPTIMIZE_REUSE_RESULTS=0;QUERY_TIMEOUT=180000;MAX_OPERATION_MEMORY=0;MAX_MEMORY_ROWS=30000;COMPRESS_LOB=NO;LOCK_MODE=0;MULTI_THREADED=0;CACHE_SIZE=1048576;TRACE_LEVEL_FILE=2;
尝试连接到现有数据库时收到以下异常:
General error: "java.lang.NullPointerException"
情景:
跟踪日志中显示的失败(最后几行):
06-02 15:32:33 jdbc[2]:
/*SQL #:1*/UPDATE UserTokens SET Timestamp_Expires = DATEADD('MINUTE', 20, Timestamp_Expires) WHERE Token = '1812493846';
06-02 15:32:33 jdbc[2]:
/*SQL #:1*/SELECT QC_Result FROM QueryCache WHERE QC_Query = 'COMMAND::usp_Engine_Metrics_FindByName||PARAM::@name%%VarChar%%50%%Hands Played||';
06-02 15:32:33 jdbc[2]:
/*SQL #:1*/SELECT RC_Result FROM ResultsCache WHERE RC_ID = '5/2/2013 12:00:00 AM_6/1/2013 11:59:59 PM__Hands Played|_Day_True____0';
06-02 15:32:33 jdbc[2]:
/*SQL #:1*/UPDATE UserTokens SET Timestamp_Expires = DATEADD('MINUTE', 20, Timestamp_Expires) WHERE Token = '1812493846';
06-02 15:32:33 jdbc[2]:
/*SQL #:1*/INSERT INTO UserState (US_ID, US_State) VALUES ('b72e861a3c04a5b1ab8282eb6605b9e0','{\"view\":\"dashboard\",\"dashboardID\":21,\"panelID\":-1,\"reportID\":-1,\"fromdate\":null,\"todate\":null,\"guid\":\"b72e861a3c04a5b1ab8282eb6605b9e0\",\"timestamp\":\"2013-06-02T12:32:33.183Z\"}');
06-02 15:35:49 jdbc[2]:
/*SQL */COMMIT;
06-02 15:35:49 jdbc[2]:
/*SQL */ROLLBACK;
06-02 15:35:49 database: disconnecting session #2
06-02 15:35:49 database: closing C:/Program Files (x86)/H2/service/dev/JarvisDB
06-02 15:35:49 database: close
java.lang.ArrayIndexOutOfBoundsException: 2048
at org.h2.store.Data.writeValue(Data.java:406)
at org.h2.store.Data.writeValue(Data.java:640)
at org.h2.index.PageBtreeIndex.writeRow(PageBtreeIndex.java:396)
at org.h2.index.PageBtreeNode.writeData(PageBtreeNode.java:446)
at org.h2.index.PageBtreeNode.write(PageBtreeNode.java:420)
at org.h2.store.PageStore.writeBack(PageStore.java:1012)
at org.h2.store.PageStore.writeBack(PageStore.java:412)
at org.h2.store.PageStore.checkpoint(PageStore.java:430)
at org.h2.engine.Database.closeOpenFilesAndUnlock(Database.java:1211)
at org.h2.engine.Database.close(Database.java:1164)
at org.h2.engine.Database.removeSession(Database.java:1043)
at org.h2.engine.Session.close(Session.java:617)
at org.h2.server.TcpServerThread.closeSession(TcpServerThread.java:177)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:272)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:151)
at java.lang.Thread.run(Unknown Source)
06-02 15:35:49 database: closed
06-02 15:35:49 database: disconnected session #2
我假设关闭连接的问题,但我确实可以使用一些指导确切的原因和解决方法。
非常感谢,
答案 0 :(得分:2)
您使用了危险选项LOG=0
(disabling the transaction log),UNDO_LOG=0
(disabling the undo log),LOCK_MODE=0
(disabling database level locking)。如果您遇到所有这些危险设置的异常,则可以预料到这一点。这是documented as well in the FAQ。
所以我建议改用默认选项。我认为以下设置应该更适合您的情况:
jdbc:h2:tcp://localhost/dev/*****;
IGNORECASE=TRUE;
QUERY_TIMEOUT=180000;
CACHE_SIZE=1048576
我会使用默认选项,除非你有一个很好的理由否:
jdbc:h2:tcp://localhost/dev/*****