连接sqlserver就是连不上,核对帐号和密码时就是连结不上数据库,这是个更改密码的小程序,怎么回事,大家帮我看看吧 拜托了
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" %>
<html>
<body bgcolor=pink>
<p>修改密码,密码长度不能超过30个字符:
<form action="" method="post">
<br>输入您的帐号:
<br><input type=text name="account">
<br>输入您的密码:
<br><input type=password name="secret">
<br>输入您的新的密码:
<br><input type=text name="newSecret1">
<br>请再输入一次您的密码:
<br><input type=text name="newSecret2">
<br><input type=submit name="g" value="提交">
</form>
<%!
public String getString(String s)
{if(s==null) s="";
try{byte a[]=s.getBytes("ISO-8859-1");
s=new String(a);
}
catch(Exception e){}
return s;
}
%>
<%
String account=request.getParameter("account");
account=getString(account);
String secret=request.getParameter("secret");
secret=getString(secret);
String newSecret1=request.getParameter("newSecret1");
newSecret1=getString(newSecret1);
String newSecret2=request.getParameter("newSecret2");
newSecret2=getString(newSecret2);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){out.print("数据库连接错误");}
Connection con=null;
Statement sql=null;
ResultSet rs=null;
boolean modify=false;
boolean ifEquals=false;
ifEquals=(newSecret1.equals(newSecret2)&&(newSecret1.length()<=30));
if(ifEquals==true){
else{
out.print("你两次输入的密码不一致或长度过大");
}
if(modify==false&&ifEqtry{
con=DriverManager.getConnection("jdbc:odbc:wangzhanrong","sa","");
sql=con.createStatement();
String condition="select * from 成绩录入人员信息表 WHERE 账号="+"'"+account+"'";
rs=sql.executeQuery(condition);
while(rs.next()){
String n=rs.getString("账号");
String s=rs.getString("密码");
if(account.equals(n)&&secret.equals(s)){
modify=true;
out.print("您的密码已经更新");
String c="update 成绩录入人员信息表 set 密码="+"'"+newSecret1+" WHERE 账号="+"'"+account+"'";
rs=sql.executeQuery(c);
}
}
}
catch(SQLException e1){};
}uals==true){
out.print("<br>您没有输入密码帐号或<br>您输入的帐号或密码不正确"+account+":"+secret);
}
%>
</body>
</html>