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

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>
...全文
74 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
fabiocappelo 2002-02-16
  • 打赏
  • 举报
回复
程序出现异常

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧