我按一下方法建立了Entity Bean为什么报错?????

happy366 2003-08-29 10:54:04
Working with entity beans
For this exercise, enter the name of the project as TestEntProject in the directory
E:\Demo\WebLogic\TestEntProject and enter the EJB module name as TestEntMod.
jdsserver.jar from <JBuilder8_Installed_Dir>\lib.
Right-click on the editor pane. Click Import Schema from Database. That brings up the
Database Schema Provider window. Enter the Database Driver, URL, Username,
Password, and JNDI name.
Driver: com.borland.datastore.jdbc.DataStoreDriver
URL:
jdbc:borland:dsremote://localhost//E:\Borland\JBuilder8\samples\JData
Store\datastores\employee.jds
JNDI name: JDSDataSource
Username: Sample
Password: <leave this empty>


For this exercise, let’s create a CMP 2.0 Entity Bean for EMPLOYEE Table. Right-click
EMPLOYEE from the structure pane and click Create CMP 2.0 Entity Bean. This creates a
Visual Employee Entity Bean in the editor pane.

Add a method (right-click EmployeeSes in the editor pane, click add, click method) to
EmployeeSes and provide the following parameters.
Method name: getEmpName
Return type: String
Input parameters: Short empNo
Interfaces: remote


public String getEmpName(Short empNo) {
String empName = "name not found";
try {
javax.naming.Context context = new
javax.naming.InitialContext();
Object object = context.lookup("java:comp/env/ejb/Employee");
EmployeeHome empHome = (EmployeeHome)
javax.rmi.PortableRemoteObject.narrow(object, EmployeeHome.class);
Employee emp = empHome.findByPrimaryKey(empNo);
empName = emp.getFirstName() + " " + emp.getLastName();
}catch (NamingException ex) {
ex.printStackTrace();
}catch (ClassCastException ex) {
ex.printStackTrace();
}catch (Exception ex){
ex.printStackTrace();
}
return empName;
}
...全文
73 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ajoke 2003-09-02
  • 打赏
  • 举报
回复
打开console控制台,添加DataSource
ajoke 2003-09-01
  • 打赏
  • 举报
回复
JNDI name: JDSDataSource
需要在server.xml里面配置(用console控制台或手工)

或者EntityBean成功发布但是它的JNDI错误?
happy366 2003-09-01
  • 打赏
  • 举报
回复
请问 如何配置server.xml里面配置?
happy366 2003-08-29
  • 打赏
  • 举报
回复
报错在
catch (NamingException ex)
Morgan_ma 2003-08-29
  • 打赏
  • 举报
回复
把错误帖出来。。。

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧