0

我在带有以下连接字符串的 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"

设想:

  • 我有一个围绕 H2 数据库的高度复杂的过程。
  • 一切正常,没有问题。
  • 当 IIS 达到空闲会话超时时,将尝试关闭任何打开的连接。
  • 跟踪日志中显示的失败(最后几行):

    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
    

我假设我关闭连接的问题,但我真的可以使用一些指导来了解确切的原因和解决方法。

非常感谢,

4

1 回答 1

2

您使用了危险选项LOG=0(禁用事务日志)UNDO_LOG=0(禁用撤消日志)LOCK_MODE=0(禁用数据库级锁定)。如果您在所有这些危险设置中遇到异常,这是可以预料的。这也记录在 FAQ 中

所以我建议改用默认选项。我认为以下设置应该更适合您的情况:

jdbc:h2:tcp://localhost/dev/*****;
    IGNORECASE=TRUE;
    QUERY_TIMEOUT=180000;
    CACHE_SIZE=1048576

我会使用默认选项,除非您有充分的理由拒绝:

jdbc:h2:tcp://localhost/dev/*****
于 2013-06-02T13:18:02.410 回答