我的第一個entity Ejb就出錯!大家幫幫忙
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)
怎麼會事?謝謝
用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)
怎麼會事?謝謝
相關文章
- 大家幫幫忙,看看這個SQL怎麼寫!SQL
- 我在安裝第一個軟體mplayer時遇到困難,請大家幫忙!(轉)
- 幫忙看看我得ejb客戶端客戶端
- 急不理解的問題,大家幫幫忙,關於jive
- 我在安裝jive的第三步中出錯了。幫幫忙!
- 這個程式就是執行不料。真著急。。大家幫幫我。。
- 一個jive的安裝問題,整整困了我5天.請大家幫忙解決
- 用過XMLHTTP的朋友幫幫忙,我這個點選後沒反應XMLHTTP
- 大家幫忙:apache每天生成一個日誌檔案?Apache
- 一道面試題:大家幫忙解決面試題
- 熟悉ibatis的請幫幫忙!BAT
- 高手幫忙
- 高手幫忙!
- 第一次系統學習j2eeturotial,ant converter 就出現錯誤!鬱悶!幫忙看看
- php5.3.3呼叫https的wsdl,出現錯誤,請大家幫忙看看PHPHTTP
- 監聽Session事件不能編譯,大家幫忙看看Session事件編譯
- 用過javamail的朋友幫幫忙,我真的沒有辦法了?!!!JavaAI
- 學習JF框架報錯,求banq老師幫幫忙框架
- 幫幫忙吧!執行程式報錯:java.lang.verifyError行程JavaError
- 安裝是遇到錯誤,大家幫我看看,謝謝
- 分頁Bean的同步問題,,請大家幫忙解決Bean
- jf6.2初學者問題,請大家幫忙看看
- 有關java的unicode編碼的問題,大家幫忙JavaUnicode
- 請高手幫忙!
- 急,高手幫忙!
- 安裝出錯,請幫忙看看(轉)
- 有關單體模式設計的問題,請大家幫忙模式
- jsp與xmlhttp在IE5.0中出現亂碼!請大家幫幫忙!JSXMLHTTP
- 本人初學JAVA請各位幫幫忙...Java
- 業務平臺的開發(高手們幫幫忙!)
- 您好, 第一章的一個問題, 清幫忙解決.
- 在jbuilder下,jive出錯。各位幫忙呀!UI
- 急!!請高手幫忙
- jbuilder高手請幫忙UI
- 請各位高手幫忙!
- 需要高手幫忙~~
- 請高手幫幫忙,給點兒資訊也行
- 請幫忙解決第一章作者忽略的兩個問題!