| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 462 人关注过本帖
标题:JSP登陆问题
取消只看楼主 加入收藏
lewis0323
Rank: 2
等 级:新手上路
威 望:3
帖 子:102
专家分:0
注 册:2006-7-20
收藏
 问题点数:0 回复次数:0 
JSP登陆问题

请问这个JAVA BEAN为什么用JSP调用显示错误呢?或者谁给我个从数据库查询用户名密码的登陆bean

package floatingpopulation;
import java.sql.*;
import java.util.*;
import java.io.*;
public class dengluBean{
String userid;
String password;
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
public void dengluBean(){
userid="";
password="";
}

public void setuserid(String user){
userid=user;}

public void setpassword(String pass){
password=pass;}

public String getuserid(){
return userid;}

public String getpassword(){
return password;}


public boolean getDataBaseUserid()throws Exception
{boolean getid=true;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}
catch(ClassNotFoundException e){e.printStackTrace();}

try{
conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=floating population","sa","");
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from student where UserName like "+"'"+userid+"'";
rs=stmt.executeQuery(sql);
if(rs.next()){
getid=true;}
else
{getid=false;}
conn.close();}
catch(SQLException e){System.out.println(e.getMessage());}
return getid;
}


public boolean validate(){
boolean ok=true;
if(userid.equals("")||userid.length()>10)
{ userid="";
ok=false;}

if(password.equals(" "))
{ password="";
ok=false;}

try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}
catch(ClassNotFoundException e){e.printStackTrace();}

try{
conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=floating population","sa","");
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from student where UserName like "+"'"+userid+"'";
rs=stmt.executeQuery(sql);
if(rs.next()){
ok=true;}
else
{ok=false;}
rs=null;
String sql1="select * from student where PassWord like "+"'"+password+"'";
rs=stmt.executeQuery(sql1);
if(rs.next())
{ok=true;}
else
{ok=false;}
conn.close();}
catch(SQLException e){System.out.println(e.getMessage());}

return ok;}

}

搜索更多相关主题的帖子: 登陆 JSP 
2006-10-24 21:40
快速回复:JSP登陆问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036071 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved