我在OSGI框架(Felix)上使用HSQLDB + EclipseLink + Gemini。儘管我已經在persistence.xml中設置了池,但我有嚴重的可疑連接池未被使用,並且每個請求都會創建一個新的連接。如何使用連接池來檢查HSQLDB端。如何檢查是否使用連接池
編輯1
我開始與-Dhsqldb.reconfig_logging=false
應用。要啓動HSQLDB服務器在我的應用程序使用下面的代碼
p.setProperty("server.database.0", "file:"+dataBasePath);
p.setProperty("server.dbname.0", "testdb");
p.setProperty("server.port", "9001");
server = new Server();
這是我的JDBC URL:
jdbc:hsqldb:hsql://localhost:9001/testdb;hsqldb.write_delay=false;hsqldb.sqllog=3;hsqldb.applog=3;server.silent=false
然而,在我的日誌我還沒有得到關於使用連接池的任何消息。這是我的日誌:
2017-04-14 11:01:57,373 | INFO | Server @48b135ed | org.hsqldb.lib.FrameworkLogger | open start - state modified
2017-04-14 11:01:57,396 | INFO | Server @48b135ed | org.hsqldb.lib.FrameworkLogger | dataFileCache open start
2017-04-14 11:01:57,407 | INFO | Server @48b135ed | org.hsqldb.lib.FrameworkLogger | dataFileCache open end
2017-04-14 11:01:57,698 | INFO | Server @48b135ed | org.hsqldb.lib.FrameworkLogger | checkpointClose start
2017-04-14 11:01:57,699 | INFO | Server @48b135ed | org.hsqldb.lib.FrameworkLogger | checkpointClose synched
2017-04-14 11:01:57,825 | INFO | Server @48b135ed | org.hsqldb.lib.FrameworkLogger | checkpointClose script done
2017-04-14 11:01:57,826 | INFO | Server @48b135ed | org.hsqldb.lib.FrameworkLogger | dataFileCache commit start
2017-04-14 11:01:57,859 | TRACE | Server @48b135ed | org.hsqldb.lib.FrameworkLogger | file sync end
2017-04-14 11:01:57,859 | INFO | Server @48b135ed | org.hsqldb.lib.FrameworkLogger | dataFileCache commit end
2017-04-14 11:01:57,934 | INFO | Server @48b135ed | org.hsqldb.lib.FrameworkLogger | checkpointClose end
EDIT 2
我在單獨的進程中啓動HSQLDB(Java的罐子..),並作爲命令行參數我加--silent false
。現在,關於這個單獨的進程控制檯我看到以下內容:
[[email protected]]: [Thread[HSQLDB Server @a09ee92,5,main]]: handleConnection(Socket[addr=/127.0.0.1,port=38959,localport=9001]) entered
[[email protected]]: [Thread[HSQLDB Server @a09ee92,5,main]]: handleConnection() exited
[[email protected]]: 3:SQLCLI:MODE:31
[[email protected]]: [Thread[HSQLDB Connection @2b14b766,5,HSQLDB Connections @a09ee92]]: 3:Trying to connect user 'SA' to DB (mydb)
[[email protected]]: [Thread[HSQLDB Connection @2b14b766,5,HSQLDB Connections @a09ee92]]: 3:Connected user 'SA'
[[email protected]]: 3:SQLCLI:SQLPREPARE SELECT * FROM foo
[[email protected]]: 3:SQLCLI:SQLEXECUTE:1
[[email protected]]: 3:SQLCLI:SQLDISCONNECT
[[email protected]]: [Thread[HSQLDB Server @a09ee92,5,main]]: handleConnection(Socket[addr=/127.0.0.1,port=38960,localport=9001]) entered
[[email protected]]: [Thread[HSQLDB Server @a09ee92,5,main]]: handleConnection() exited
[[email protected]]: 4:SQLCLI:MODE:31
[[email protected]]: [Thread[HSQLDB Connection @f5cabc4,5,HSQLDB Connections @a09ee92]]: 4:Trying to connect user 'SA' to DB (mydb)
[[email protected]]: [Thread[HSQLDB Connection @f5cabc4,5,HSQLDB Connections @a09ee92]]: 4:Connected user 'SA'
[[email protected]]: 4:SQLCLI:SQLPREPARE SELECT * FROM test WHERE id IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?))
[[email protected]]: 4:SQLCLI:SQLEXECUTE:1
[[email protected]]: 4:SQLCLI:MODE:18
[[email protected]]: 4:SQLCLI:SQLDISCONNECT
此行HSQLDB Connection @XXXXXXXX
不同,每次查詢,此外,每次查詢我看到Trying to connect user 'SA' to DB (mydb)
。這是否意味着連接池不被使用?
我對HSQLDB的管理沒有太多瞭解,但是您不能檢查日誌以查看何時創建新連接?最糟糕的情況是,查看文檔:「*服務器或WebServer實例可以使用屬性server.silent = false啓動。這會導致所有連接及其執行的語句在語句提交到服務器時打印到標準輸出。 *「 –
作爲服務器運行,並按照上面的建議'server.silent = false'。這是最簡單的選擇。 – fredt
@fredt請參閱我的編輯1 –