description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: An exception occurred processing JSP page /denglu.jsp at line 2522: username=request.getParameter("username");
23: pwd=request.getParameter("pwd");
24: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
25: Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=liuyanban","sa","123qwe");
26: Statement stmt=conn.createStatement();
27:
28: ResultSet rs=stmt.executeQuery("select * from zhucebiao where username=\'"+username+"\' and password=\'"+pwd+"\'");
求解这些异常!!!多谢
23: pwd=request.getParameter("pwd");
24: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
25: Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=liuyanban","sa","123qwe");
26: Statement stmt=conn.createStatement();
27:
28: ResultSet rs=stmt.executeQuery("select * from zhucebiao where username=\'"+username+"\' and password=\'"+pwd+"\'");
求解这些异常!!!多谢
<%
try
{
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("....");
}catch(Exception e){out.println("shibai");}
%>
PS:把数据库的东西写到一个类中,然后调用比较好
PreparedStatement可以代替Statement了
这里应该是com.microsoft.jdbc.sqlserver.SQLServerDriver吧、
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=liuyanban","sa","123qwe");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from zhucebiao where username=\'"+username+"\' and password=\'"+pwd+"\'");
}catch(Exception e){e.printStackTrace();}
即使不用debug 你用个最简单的方法 System.out.println一下啊
你看一下conn的值啊 是否建立成功
然后看你导入包对不对。你现在的Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=liuyanban","sa","123qwe");是sql2000的。
如果是2005的话应该是
conn=DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DataBaseName=company","sa","sa");
没有那个:microsoft: