| 問題:web每次請求都會動態(tài)連接數(shù)據(jù)庫;dbname是個數(shù)據(jù)庫名參數(shù), private Connection getConn() throws SQLException{Connection conn=null;
 try {
 Class.forName("SQLite.JDBCDriver");
 } catch (ClassNotFoundException e) {
 e.printStackTrace();
 }
 if(dbName!=null&&dbName.length()>4){
 conn=DriverManager.getConnection("jdbc:sqlite:/c:\\sqlite3\\"+dbName+".db");
 }
 return conn;
 }
 原因:重重加載同一個文件;   錯誤表明sqlite_jni.dll已經(jīng)被JVM的ClassLoader load了。通過查閱資料發(fā)現(xiàn)Web  Server的自動重啟機(jī)制是產(chǎn)
生這一問題的根源。當(dāng)Resin重啟包含sqlite_jni.dll的這個Web應(yīng)用時,會因為Variant類的語句而自動執(zhí)行
jsqlite_jni.dll的加載。但重啟Web應(yīng)用并不是重啟整個resin(即:上一次啟動的JVM仍然存在),也就是說
sqlite_jni.dll已經(jīng)被加載過了,因此系統(tǒng)將拋出錯誤。而當(dāng)我們手工重啟resin時,則會將上一次啟動的JVM關(guān)閉并重新啟動,這時會正常
加載sqlite_jni.dll。
     解決:把sqlite.jar即sqlite jdbc驅(qū)動放到resion/tomcat中的公共lib目錄下;而不是放在應(yīng)用即:web-inf/lib下;        因為sqlite.jar中,有sqlite_jni.dll文件加載的調(diào)用類; 
 
 原文章地址:http://blog.csdn.net/yangsp1/archive/2009/04/23/4103065.aspx
 |