📄 readerjavabean.java
字号:
package library.jb;
import java.util.*;
import java.sql.*;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;
import library.ejb.*;
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//这是一个JavaBean类,这个类是用来连接JSP脚本和Entity Bean中的Home接口
//及Remote接口的。当用户点击JSP网页中的某项操作时,由ReaderJavaBean来调用
//Home接口或Remote接口中的某一个方法进行处理。
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class ReaderJavaBean
{
ReaderInfoHomeInt readerinfohomeint = null;
private String readname = null;
private String cardid = null;
private String password = null;
private String address = null;
private String email = null;
public ReaderJavaBean() throws Exception
{
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//建立一个ReaderJavaBean类的构造器
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
try
{
Context initcontext = new InitialContext();
Object obj = initcontext.lookup("ejb/LibraryEntityBean");
readerinfohomeint = (ReaderInfoHomeInt)PortableRemoteObject.narrow(obj,ReaderInfoHomeInt.class);
}
catch(Exception e)
{
throw new Exception(e.toString());
}
}
public void updateReaderInfo() throws Exception
{
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//实现对数据记录的更新
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
try
{
ReaderInfoRemoteInt readerinforemoteint = readerinfohomeint.findByPrimaryKey(cardid);
readerinforemoteint.setReaderInfo(readname,cardid,password,address,email);
}
catch(Exception e)
{
throw new Exception("系统出现例外,无法更新数据!");
}
}
public void insertReaderInfo() throws Exception
{
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//实现将一条新的记录插入到数据表中
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
try
{
ReaderInfoRemoteInt readerinforemoteint = readerinfohomeint.create(readname,cardid,password,address,email);
password=readerinforemoteint.getPassword();
}
catch(Exception e)
{
throw new Exception("系统出现例外,无法添加新的数据!");
}
}
public void cancelReaderInfo() throws Exception
{
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//实现将一个读者的信息从数据表中删除
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
try
{
ReaderInfoRemoteInt readerinforemoteint = readerinfohomeint.findByPrimaryKey(cardid);
readerinforemoteint.remove();
}
catch(Exception e)
{
throw new Exception("系统出现例外,无法删除数据!");
}
}
public int isRegReader() throws Exception
{
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//实现判断一个登录者是否已经注册
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int isReader = 0;
try
{
ReaderInfoRemoteInt readerinforemoteint = readerinfohomeint.findByPrimaryKey(cardid);
if(readerinforemoteint.getCardID().equals(cardid) && readerinforemoteint.getPassword().equals(password))
{
isReader = 1;
}
else
{
isReader = 0;
}
}
catch(Exception e)
{
isReader = 0;
}
return isReader;
}
public void setReadname(String readname)
{
this.readname = readname;
}
public String getReadname()
{
return this.readname;
}
public void setCardid(String cardid)
{
this.cardid = cardid;
}
public String getCardid()
{
return this.cardid;
}
public void setPassword(String password)
{
this.password = password;
}
public String getPassword()
{
return this.password;
}
public void setAddress(String address)
{
this.address = address;
}
public String getAddress()
{
return this.address;
}
public void setEmail(String email)
{
this.email = email;
}
public String getEmail()
{
return this.email;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -