?? 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 + -