我有一個play 2.1應用程序,我正在使用junit進行單元測試。我的測試運行良好,並且能夠執行他們的數據庫操作。顯然驅動程序(org.postgresql.Driver
)已加載。沒有找到合適的連接池驅動程序
但是,在測試之間,看起來連接池無法訪問驅動程序。以下是我日誌中典型序列的摘錄。有誰知道爲什麼連接池在應用程序沒問題時可能無法訪問驅動程序?
[info] application - QuickWitness Server shutdown...
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 10. Exception: null
[error] c.j.b.ConnectionHandle - Database access problem. Killing off all remaining connections in the connection pool. SQL State = 08001
[error] c.j.b.PoolWatchThread - Error in trying to obtain a connection. Retrying in 1000ms
java.sql.SQLException: No suitable driver found for jdbc:postgresql:qw
at java.sql.DriverManager.getConnection(DriverManager.java:602) ~[na:1.6.0_26]
at java.sql.DriverManager.getConnection(DriverManager.java:185) ~[na:1.6.0_26]
at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:256) ~[bonecp.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.ConnectionHandle.obtainInternalConnection(ConnectionHandle.java:211) ~[bonecp.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.ConnectionHandle.<init>(ConnectionHandle.java:170) ~[bonecp.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.PoolWatchThread.fillConnections(PoolWatchThread.java:101) [bonecp.jar:0.7.1.RELEASE]
[info] application - QuickWitness Server has started
[debug] application - entering ensureTriggersAndStoredProceduresAreInstalled()
[debug] application - exiting ensureTriggersAndStoredProceduresAreInstalled()
[info] application - logging initialized
[info] application - Register user request from localhost:12345
[info] application - QuickWitness Server shutdown...
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 10. Exception: null
[error] c.j.b.ConnectionHandle - Database access problem. Killing off all remaining connections in the connection pool. SQL State = 08001
[error] c.j.b.PoolWatchThread - Error in trying to obtain a connection. Retrying in 1000ms
java.sql.SQLException: No suitable driver found for jdbc:postgresql:qw
at java.sql.DriverManager.getConnection(DriverManager.java:602) ~[na:1.6.0_26]
at java.sql.DriverManager.getConnection(DriverManager.java:185) ~[na:1.6.0_26]
at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:256) ~[bonecp.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.ConnectionHandle.obtainInternalConnection(ConnectionHandle.java:211) ~[bonecp.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.ConnectionHandle.<init>(ConnectionHandle.java:170) ~[bonecp.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.PoolWatchThread.fillConnections(PoolWatchThread.java:101) [bonecp.jar:0.7.1.RELEASE]
[info] application - QuickWitness Server has started
那麼在Play環境中運行時,您是如何使驅動程序可用的? – 2013-03-02 14:56:25
我在application.conf文件中指定了驅動程序的名稱: db.default.driver = org.postgresql.Driver 驅動程序的jar在類路徑中。 – user2102276 2013-03-04 00:57:44
你確定*它在類路徑中嗎?你怎麼把它放在類路徑中?我懷疑這就是問題所在。 – 2013-03-04 07:37:21