用户名和密码保存在user数据表中,下面是我的处理界面,要怎么写呢?实现的功能是:从index.jsp获得的数据传递到判断界面进行处理,如果和数据中保存的数据以致就登录。<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="java.util.*" %>
<%@page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>身份验证</title>
</head>
<body><%
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url="jdbc:sqlserver://localhost:1433;DatabaseName=user"; request.setCharacterEncoding("GB18030");
String name = request.getParameter("userName");
String password = request.getParameter("password");Connection conn = DriverManager.getConnection(url,name,password);
if (conn!=null){
out.print("数据库操作成功,恭喜你");
}%>
</body>
</html>
pageEncoding="GB18030"%>
<%@ page import="java.util.*" %>
<%@page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>身份验证</title>
</head>
<body><%
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url="jdbc:sqlserver://localhost:1433;DatabaseName=user"; request.setCharacterEncoding("GB18030");
String name = request.getParameter("userName");
String password = request.getParameter("password");Connection conn = DriverManager.getConnection(url,name,password);
if (conn!=null){
out.print("数据库操作成功,恭喜你");
}%>
</body>
</html>
解决方案 »
- struts1表格列显示问题
- 从正文A.txt读入英文短文,统计不同单词和出现次数,并按词典顺序将单词及出现次数输出到B.txt
- struts2 验证框架
- 图片保存在windows和linix下。代码一样,但是linix下出异常。。。。
- Ext实现文件下载
- 关于weblogic出现“can't find driver class”异常
- rmi 简单问题,up有分。
- 请问谁知道哪里有jetspeed的中文资料?
- myeclipse10整合ssh框架时发生Error occured processing XML 'Provider org.apache.xer。。。。
- 在eclipse中启动Eureka报以下错误,但是在IDEA里不报错
- Spring中为什么实体类不用注入?
- 求高手赐教ajax搜索引擎
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage 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 /judge.jsp at line 3027:
28:
29:
30: Connection conn = DriverManager.getConnection(url,name,password);
31:
32:
33: if (conn!=null){
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause javax.servlet.ServletException: com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'abc' 登录失败。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
org.apache.jsp.judge_jsp._jspService(judge_jsp.java:111)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'abc' 登录失败。
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(Unknown Source)
com.microsoft.sqlserver.jdbc.TDSParser.parse(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(Unknown Source)
com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
java.sql.DriverManager.getConnection(DriverManager.java:582)
java.sql.DriverManager.getConnection(DriverManager.java:185)
org.apache.jsp.judge_jsp._jspService(judge_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs.
--------------------------------------------------------------------------------Apache Tomcat/6.0.32
这句好的意思是获取数据库连接,name和password是登陆mysql的用户名和密码(一般是root/root),而楼主你你登陆页面的用户名和密码当成数据库的用户名和密码了,导致用户名报错
ps:一般数据库用户名和密码是后台配置的