我的第一个entity Ejb就出错!大家帮帮忙

04-03-20 asdlcj

1.

用jb8+wls70+mssql2000

写了一个 表employees的entity ejb

用sessionbean分装,

有一个getEmpName的方法如下,根据empid返回姓名!

public String getEmpName(Integer empID) {

/**@todo Complete this method*/

String empName="name not found!";

try{

javax.naming.Context context=new javax.naming.InitialContext();

Object object=context.lookup("java:comp/env/ejb/Employees");

EmployeesHome empHome=(EmployeesHome)

javax.rmi.PortableRemoteObject.narrow(object,EmployeesHome.class);

Employees emp=empHome.findByPrimaryKey(empID);

empName=emp.getFirstName()+""+emp.getLastName();

}

catch(NamingException ex){

ex.printStackTrace();

}

catch(ClassCastException ex){

ex.printStackTrace();

}

catch(Exception ex){

ex.printStackTrace();

}

return empName;

}

2.配置好wls的数据源连接池(已经连接成功)和java:comp/env/ejb/Employees引用

运行jb和wls

部署程序

写了一个testclient

main方法如下

public static void main(String[] args) {

employeesSesTestClient client = new employeesSesTestClient();

// Use the client object to call one of the Home interface wrappers

// above, to create a Remote interface reference to the bean.

// If the return value is of the Remote interface type, you can use it

// to access the remote interface methods. You can also just use the

// client object to call the Remote interface wrappers.

try {

client.create();

String empName=client.getEmpName(new Integer("1"));

System.out.println("Name from the test client="+empName);

}

catch(Exception ex){

ex.printStackTrace();

}

}

运行testcilent

控制台抛出错误如下

javax.ejb.FinderException: Problem in findByPrimaryKey while preparing or executing statement: 'weblogic.jdbc.rmi.SerialPreparedStatement@6a66b':

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 1.

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 1.

at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)

at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)

怎么会事?谢谢

asdlcj
2004-03-22 12:54

bangq老师帮帮忙啊

banq
2004-03-22 13:02

不是不帮你,我对weblogic不精通啊,JBoss没问题。

asdlcj
2004-03-23 12:16

哦 !不过还是要谢谢啊!

我自己再研究一下!

顺便问一下bangq老师:

jbuilder8-jboss3.0的插件哪里可以下载?

asdlcj
2004-03-23 12:18

是jbuilder8.0-jboss3.2.1的!那里有啊?