缠绕了我两天的问题:操作数据库的语句不被执行???
rjane 2002-02-15 11:26:25 我做一登陆界面,具体代码如下,但我即使输入数据库里存在的userid ,password还是显示the user doesn't exist!有谁能告诉我这是怎么回事吗?万分感谢!
<body>
<%
String userId=request.getParameter("userId");
String password=request.getParameter("password");
if((userId.length()==0)||(password.length()==0))
out.println("userId or password not null!");
else
{
try{
Class.forName("sun.jdbc.odbc.jdbcOdbcDriver");
String url="jdbc:odbc:erp";
Connection con=DriverManager.getConnection(url,"sa","");
PreparedStatement select_stm=con.prepareStatement("select password from dbo.czy where userId=?");
select_stm.setString(1,userId);
ResultSet result=select_stm.executeQuery();
String temp_password=null;
if(result.next())
{
temp_password=result.getString(1);
}
result.close();
con.close();
if(password.regionMatches(0,temp_password,0,password.length()))
out.println("Welcome !");
else out.println("You are not right one!");
}
catch(Exception e)
{out.println("the user doesn't exist");}
%>
<%}
%>
</body>