我有一個可怕的Tomcat問題,因爲這個問題非常糟糕我已經拋棄了一個多月的項目......然而,我仍然需要去解決它,並與項目去......Tomcat錯誤:java.sql.SQLException:沒有找到適合jdbc的驅動程序:sqlserver://
所以它拋出我這個錯誤:
值java.sql.SQLException:找到了JDBC沒有合適的驅動程序: sqlserver://isd.ktu.lt:1433; DatabaseName = LN2012_bakDB2 java.lang.NullPointerException
問題是同一個應用程序在deskto中工作p版本perfectlz,但是當涉及到應該在服務器上運行的版本(NetBeans 7.1.2中的Tomcat 7.0.22.0)時,它只會引發錯誤。現在看來,這不加載的驅動程序池還是我甚至不知道......
那麼這裏的負責的部分:
public DatabaseConnection(Parameters params) {
// parameters and the output
this.gui = params.getGui();
// activate database pool
connectionPool = new GenericObjectPool(null);
connectionFactory = new DriverManagerConnectionFactory(params.getDbAdr(), params.getDbUser(), params.getDbPass());
poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true);
driver = new PoolingDriver();
driver.registerPool("GenTreeDatabase", connectionPool);
//driver.registerPool("jdbc:apache:commons:dbcp:GenTreeDatabase", connectionPool);
}
public void openConn() {
if (allowOutput) gui.print("Getting connection to database");
try {
con = DriverManager.getConnection("jdbc:apache:commons:dbcp:GenTreeDatabase");
if (con != null) {
if (allowOutput) gui.print("Connection to database was successful");
}
} catch (SQLException ex) {
gui.err(specificError + "Error getting connection to database - " + ex);
}
}
它發生在它嘗試獲取點連接,那麼它會得到一個空指針異常,因爲連接不會被成功檢索。
我對Tomcat並不熟悉,直到現在,Netbeans處理了tomcat罰款... 事情是我討厭這樣的錯誤...如果你在三天內沒有解決它,沮喪,不想回到那個,你覺得打牆... 現在我試着用google搜索很多,但仍然沒有太多的幫助... 所以我會真的很高興有人能幫助我。謝謝。 :)
請顯示堆棧跟蹤! – home 2012-07-08 11:55:39
位於Tomcat目錄中的數據庫驅動程序(例如sqljdbc4.jar)在哪裏? – 2012-07-08 19:10:46
@MartinWilson它位於C:\ Program Files \ Apache Software Foundation \ Apache Tomcat 7.0.22 \ lib – 2012-07-09 11:17:53