String userid = request.getParameter("uname");
String pwd = request.getParameter("pass");
Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:db2://localhost:50000/TEST","root","atul");
Statement st = con.createStatement();
ResultSet rs;
rs = st.executeQuery("select * from members where uname='" + userid + "' and pass='" + pwd"'");
if (rs.next()) {
session.setAttribute("userid", userid);
//out.println("welcome " + userid);
//out.println("<a href='logout.jsp'>Log out</a>");
response.sendRedirect("success.jsp");
} else {
out.println("Invalid password <a href='index.jsp'>try again</a>");
}
%>
我已安装db2 v9.7并在ecilpse的目录web-inf / lib(db2jcc.jar和db2jcc.jar)中使用jdbc连接器v9.7fp5_jdbc_sqlj用于db2,并在db2中使用用户名创建数据库测试:root ans password:阿图尔。我在我的系统中安装了db2。我已经多次重启tomcat,实际上多次重启我的电脑,搜索谷歌并发现上面的代码。错误是
HTTP Status 500 - An exception occurred processing JSP page /login.jsp at line 18
type Exception report
message An exception occurred processing JSP page /login.jsp at line 18description. The
server encountered an internal error that prevented it from fulfilling this request
request.
栈跟踪
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)