懂javaBean的高手进
bean的源程序:
package test;
import java.sql.*;
public class Login
{
String users= " ";
String usertype= " ";
String password= " ";
String success= "false ",
message= " ";
public Login()
{
try{Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
}
catch(
ClassNotFoundException e){}
}
public void setuserType(String No)
{
usertype=No;
}
public String getuserType()
{
return usertype;
}
public void setUsers(String name)
{
users=name;
}
public String getUsers()
{
return users;
}
public void setPassword(String number)
{
password=number;
}
public String getPassword()
{
return password;
}
public String getMessage()
{
Connection con;
Statement sql;
ResultSet rs;
try{
con=DriverManager.getConnection( "jdbc:odbc:sun ", "sa ", " ");
sql=con.createStatement();
String condition= "select * from user WHERE users= "+ " ' "+users+ " ' ";
rs=sql.executeQuery(condition);
int rowcount=0;
String ps= " ";
String bs= " ";
while(rs.next())
{
rowcount++;
users=rs.getString( "users ");
ps=rs.getString( "password ");
bs=rs.getString( "usertype ");
}
if((rowcount==1)&&(password.equals(ps))&&(usertype.equals(bs)))
{
message= "ok ";
success= "ok ";
}
else
{
message= "输入的用户名或密码不正确 ";
success= "false ";
}
con.close();
return message;
}
catch(
SQLException e)
{
message= "输入的用户名或密码不正确 ";
success= "false ";