jsp登陆注册页面的完整代码,链接access或sql

来源:百度知道 编辑:UC知道 时间:2024/06/06 04:16:25
希望大家是以文件(jsp文件和access或sql)的形式发到我的邮箱去,邮箱:304994738@qq.com

以下是和sql2000连接的,字段名只是参考,相信对你有帮助。如果是和其他数据库连接只要修改连接部分的语句。不懂的地方问我!
这个是登陆的代码:
<%
String no=new String();
no=request.getParameter("no");
String psw=new String();
psw=request.getParameter("psw");
Connection con=null;
Statement sql=null;
ResultSet rs=null;
try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); }

catch(ClassNotFoundException e){}

try{con=DriverManager.getConnection("jdbc:odbc:sun","sa","密码");

sql=con.createStatement();
String condition="select * from studentInfo where sid= "+"'"+no+"'"+" and psw= "+"'"+psw+"'";
rs=sql.executeQuery(condition);
if(rs.next()==false)
{out.println("密码或用户名不正确!您现在是游客身份!");}
else {out.println("登陆成功,欢迎您,"+rs.getString("name"));}
con.close();
}
ca