狀況: 執行Class.forName(driverName).newInstance(); eclipse出現error訊息:unhandled exception type IllegalAccessException 原因: Class.forName("com.mysql.jdbc.Driver").newInstance(); 這行程式需要exception操作,要做try catch或throws, 而在jsp中,eclipse對於採用<% %>方式寫的程式碼不做異常檢查,因為JSP預設會做try catch。 解決方法: try{ Class.forName(driverName).newInstance(); } catch(Exception e){ //for catch Class.forName exception }