測(cè)試數(shù)據(jù)庫(kù)連接成功,但是訪問(wèn)servlet時(shí)出現(xiàn)注冊(cè)驅(qū)動(dòng)失敗錯(cuò)誤
寫到查詢學(xué)生數(shù)據(jù)的部分時(shí),單獨(dú)運(yùn)行數(shù)據(jù)庫(kù)連接工具類,運(yùn)行結(jié)果為數(shù)據(jù)庫(kù)連接成功
而在訪問(wèn)servlet時(shí),卻出現(xiàn)http status 500-注冊(cè)驅(qū)動(dòng)失敗的錯(cuò)誤
getConnection()函數(shù)如下:
public static Connection getConnection(){
try{
Class.forName(driver);
Conn=DriverManager.getConnection(url,username,password);
System.out.println(“數(shù)據(jù)庫(kù)連接成功”);
}catch(Exception e)
{
throw new RuntimeException(“注冊(cè)驅(qū)動(dòng)失敗”);}
return conn;
}
訪問(wèn)servlet之后,出現(xiàn)的錯(cuò)誤提示為:
Servlet.service() for servlet [SubListServlet] in context with path [/SubListDemo] threw exception
請(qǐng)問(wèn)有哪位遇到過(guò)這種問(wèn)題啊,求解答,謝謝大家???
2018-04-11
sublistServlet中增加參數(shù),request.setAttribute("stuName",stuName);和request.setAttribute("gender",gender)
2018-03-18
我也是總出這個(gè)問(wèn)題,心累