求用JSP做的登陆,连接数据库(SQL2000),查询数据库,添加、修改、删除
来源:百度知道 编辑:UC知道 时间:2024/06/01 01:14:29
求用JSP做的登陆,连接数据库(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();
}
catch(SQLException e1){}
%>
下面是注册的代码