先谢谢两位! 我有现成的例子是,在网上下载的:Cabin.java ------------------- package com.titan.cabin;import java.rmi.RemoteException;public interface Cabin extends javax.ejb.EJBObject { public String getName() throws RemoteException; public void setName(String str) throws RemoteException; public int getDeckLevel() throws RemoteException; public void setDeckLevel(int level) throws RemoteException; public int getShip() throws RemoteException; public void setShip(int sp) throws RemoteException; public int getBedCount() throws RemoteException; public void setBedCount(int bc) throws RemoteException; } ------------------- CabinHome.java ------------------- package com.titan.cabin;import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.ejb.FinderException;public interface CabinHome extends javax.ejb.EJBHome { public Cabin create(int id) throws CreateException, RemoteException; public Cabin findByPrimaryKey(CabinPK pk) throws FinderException, RemoteException; } --------------------CabinBean.java -------------------- package com.titan.cabin;import javax.ejb.EntityContext;public class CabinBean implements javax.ejb.EntityBean { public int id; public String name; public int deckLevel; public int ship; public int bedCount;
public CabinPK ejbCreate(int id){ this.id = id; return null; } public void ejbPostCreate(int id){ // Do nothing. Required. } public String getName(){ return name; } public void setName(String str){ name = str; } public int getShip(){ return ship; } public void setShip(int sp) { ship = sp; } public int getBedCount(){ return bedCount; } public void setBedCount(int bc){ bedCount = bc; } ----------------------CabinPK.java ---------------------- package com.titan.cabin;public class CabinPK implements java.io.Serializable { public int id; public int hashCode( ){ return id; } public boolean equals(Object obj){ if(obj instanceof CabinPK){ return (id == ((CabinPK)obj).id); } return false; } public String toString(){ return String.valueOf(id); }
先看看书,很多书已经有很实在的例子了。good luck!
我有现成的例子是,在网上下载的:Cabin.java
-------------------
package com.titan.cabin;import java.rmi.RemoteException;public interface Cabin extends javax.ejb.EJBObject {
public String getName() throws RemoteException;
public void setName(String str) throws RemoteException;
public int getDeckLevel() throws RemoteException;
public void setDeckLevel(int level) throws RemoteException;
public int getShip() throws RemoteException;
public void setShip(int sp) throws RemoteException;
public int getBedCount() throws RemoteException;
public void setBedCount(int bc) throws RemoteException;
}
-------------------
CabinHome.java
-------------------
package com.titan.cabin;import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;public interface CabinHome extends javax.ejb.EJBHome { public Cabin create(int id)
throws CreateException, RemoteException; public Cabin findByPrimaryKey(CabinPK pk)
throws FinderException, RemoteException;
}
--------------------CabinBean.java
--------------------
package com.titan.cabin;import javax.ejb.EntityContext;public class CabinBean implements javax.ejb.EntityBean { public int id;
public String name;
public int deckLevel;
public int ship;
public int bedCount;
public CabinPK ejbCreate(int id){
this.id = id;
return null;
}
public void ejbPostCreate(int id){
// Do nothing. Required.
}
public String getName(){
return name;
}
public void setName(String str){
name = str;
}
public int getShip(){
return ship;
}
public void setShip(int sp) {
ship = sp;
}
public int getBedCount(){
return bedCount;
}
public void setBedCount(int bc){
bedCount = bc;
}
----------------------CabinPK.java
----------------------
package com.titan.cabin;public class CabinPK implements java.io.Serializable {
public int id; public int hashCode( ){
return id;
}
public boolean equals(Object obj){
if(obj instanceof CabinPK){
return (id == ((CabinPK)obj).id);
}
return false;
}
public String toString(){
return String.valueOf(id);
}
}
----------------------都已经编译好了,现在想用sun的j2sdkee1.3.1发布。例子里面要求建
一个表,我在mysql已经把表建好,但是要在j2sdkee中怎么设置呢?
2,编译你的文件,java *.java
3,调出那个deploytool
4,部署ejb
5,deloy ejb
6,run your jar可能不是很详细,大概差不多是这样了