Topic: 求助:关于jboss查找实体bean的问题

  Print this page

1.求助:关于jboss查找实体bean的问题 Copy to clipboard
Posted by: tozx96
Posted on: 2003-07-13 18:57

我写了两个cmp1.1,名称分别是TestPerson和EstItem,然后我写了一个sessionbean,名成为EnterpriseBean1,我的目的就是在EnterpriseBean1查找相应的实体bean,代码如下:
Collection estItemCol = estItemHome.findSystemItem();
System.out.println(estItemCol.size() );
Iterator iteEstItem = estItemCol.iterator() ;
while(iteEstItem.hasNext() ){
Object obj = iteEstItem.next() ;
EstItem estItem = (EstItem)PortableRemoteObject.narrow(obj,EstItem.class);
System.out.println(estItem.getItemName() );
}

Collection testPersonCol = testPersonHome.findByIdAndName("200307000001","a");
System.out.println(testPersonCol.size() );
Iterator ite = testPersonCol.iterator() ;
while(ite.hasNext() ){
Object obj = ite.next() ;
TestPerson testPerson = (TestPerson)PortableRemoteObject.narrow(obj,TestPerson.class);
System.out.println(testPerson.getPersonName());
}
这段代码的目的就是输出两个实体bean的fander方法的结果,但是执行到estItem.getItemName() 出下了如下异常:
18:34:49,853 ERROR [JDBCCommand] Exception caught executing SQL
java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]ResultSet can not re-re
ad row data for column 1.(后面还有很长的异常信息,但可能没用,所以就写出来)
更奇怪的是testPerson.getPersonName()又不会出现这个异常。
请各位高手指点。非常谢谢。

2.Re:求助:关于jboss查找实体bean的问题 [Re: tozx96] Copy to clipboard
Posted by: why
Posted on: 2003-07-13 19:29

This "ResultSet can not re-read" problem is not unpopular.
If your query returns column of type 'image' or 'text' or 'ntext', then it's a restriction -- you have to call the getXXX() methods in order.
Otherwise, it's most likely a bug of SQL Server JDBC driver.
Try another JDBC driver.

3.Re:求助:关于jboss查找实体bean的问题 [Re: tozx96] Copy to clipboard
Posted by: tozx96
Posted on: 2003-07-13 19:53

非常谢谢。
不过还是不理解getXXX()怎么用?能否说详细些?再次谢谢。

4.Re:求助:关于jboss查找实体bean的问题 [Re: tozx96] Copy to clipboard
Posted by: tozx96
Posted on: 2003-07-13 20:22

我是不是得把cmp改写成bmp,然后再在bmp的ejbLoad()方法中用getXXX()来处理?

5.Re:求助:关于jboss查找实体bean的问题 [Re: tozx96] Copy to clipboard
Posted by: why
Posted on: 2003-07-13 20:37

I didn't have CMP in my mind when I wrote getXXX() Embaressed
if the sql statement is SELECT a, b, c, d FROM t
then the columns a, b, c, d must be retrieved in order, i.e. ab, acd, cd, but not da etc.

You can 改写成bmp if you wish, but I would just use another JDBC driver.Wink

6.Re:求助:关于jboss查找实体bean的问题 [Re: tozx96] Copy to clipboard
Posted by: tozx96
Posted on: 2003-07-13 21:48

非常谢谢。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923