缠绕了我两天的问题:操作数据库的语句不被执行???

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>
...全文
4 点赞 收藏 1
写回复
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
fabiocappelo 2002-02-16
程序出现异常
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告