• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Fetch Exception In Entity Bean

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I am deploying an entity bean using jetace and admin console, with oracle database, when i ever I access that bean thro' client, the create and find method are working fine, but when i try to display the field values or access any business method I am getting FETCH EXCEPTION as shown below, I have also given the client code also, Is there any condition that order of columns in table should be similar to one in xml file, if so can anybody explain.
Caught an unexpected exception!
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
com.ibm.ejs.persistence.EJSPersistenceException: java.sql.SQLException: ORA-01002: fetch out of sequence
; nested exception is:
java.sql.SQLException: ORA-01002: fetch out of sequence
com.ibm.ejs.persistence.EJSPersistenceException: java.sql.SQLException: ORA-01002: fetch out of sequence
; nested exception is:
java.sql.SQLException: ORA-01002: fetch out of sequence
java.sql.SQLException: ORA-01002: fetch out of sequence
CLIENT SOURCE CODE:
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import dept.*;
public class MyDeptClient {
public static void main(String[] args) {
try {
Properties props = System.getProperties();
props.put( javax.naming.Context.PROVIDER_URL, "iiop://localhost:900" );
props.put( javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory" );
Context initial = new InitialContext(props);
//HelloHome home =(HelloHome) initial.lookup("HelloHome");
Object objref =initial.lookup("MyDept");
MyDeptHome home =
(MyDeptHome)PortableRemoteObject.narrow(objref, MyDeptHome.class);
MyDept a = home.create( new MyDeptKey(30),"");
//Enumeration e = home.findLargeMyAccounts(199999.0f);
/* if ( e == null )
System.out.println( "NULL"+e.hasMoreElements() );
else
System.out.println( "Not NULL"+e.hasMoreElements() );*/
// MyAccount a = home.create(new MyAccountKey(1001), 1, 1000.00f);
System.out.println( "DeptName " + (a.getRecord())[0]);
} catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
}
 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
what the error means is : that your cursor is no longer valid
this is an oracle error
check out this link http://technet.oracle.com/support/bboard/content/647.htm
 
Mey Mey
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,
Its an Oracle exception, I think, its happening due to ordering of column in xml file and oracle table, I read a document saying when u use VAJ u won't get such problem, when I deploy the eg. jar file I am not getting the same, but when I rename the same and deploy as my own bean then I am getting the error.
Still it the problem exist.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can copy the code for the bean on this board, I can look into it give u some suggestions. The client code is ok.
 
Mey Mey
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jose,
I am coping, the entire code stuffs, go thro it and give a solution, package dept;
REMOTE INTERFACE
/**
* The remote interface of the MyDept entity bean.
*/
import java.rmi.*;
import javax.ejb.*;
public interface MyDept extends EJBObject {
String[] getRecord() throws RemoteException;
}
HOME INTERFACE
package dept;
/**
* The home interface of the MyDept entity bean.
**/
import java.rmi.*;
import java.util.*;
import javax.ejb.*;
public interface MyDeptHome extends javax.ejb.EJBHome {
MyDept create(MyDeptKey id) throws CreateException, RemoteException;
MyDept create(MyDeptKey id, String deptName) throws CreateException, RemoteException;
public MyDept findByPrimaryKey(MyDeptKey id) throws RemoteException, FinderException;
Enumeration findByDepartmentName(String deptName) throws RemoteException, FinderException;
}
FINDER HELPER CLASS
package dept;
/**
* The finder helper interface of the MyAccount entity bean.
* For each finder method defined in the home interface other than the create and
* findByPrimaryKey methods, a query Sting must be defined here.
*
* These query strings will be referenced by the finder implementation class generated by the
* deployment tool.
**/
public interface MyDeptBeanFinderHelper {
public static final String findByDepartmentNameQueryString = "select * from ejb.MyDeptBeantbl where deptName=?";
}
KEY CLASS
package dept;
/**
* The key class of the MyDept entity bean.
**/
import java.io.*;
public class MyDeptKey implements Serializable {
public long deptNo;
/**
* Constructs an MyDeptKey object.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
public MyDeptKey() {
super();
}
/**
* Constructs a newly allocated MyDeptBMKey object that represents the primitive long argument.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
public MyDeptKey(long deptNo) {
this.deptNo = deptNo;
}
public long asLong() {
return deptNo;
}
/**
* Determines if the MyDeptKey object passed to the method matches this MyAccountKey object.
* @param o java.lang.Object The MyDeptKey object to compare to this MyAccountKey object.
* @return boolean The pass object is either equal to this MyDeptBMKey object (true) or
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
public boolean equals(Object o) {
if (o instanceof MyDeptKey) {
MyDeptKey otherKey = (MyDeptKey) o;
return (((deptNo == otherKey.deptNo)));
}
else {
return false;
}
}
/**
* Generates a hash code for this MyDeptKey object.
* @return int The hash code.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
public int hashCode() {
return ((new Long(deptNo).hashCode()));
}
}

BEAN CLASS
package dept;
/**
* The bean class of the MyAccount entity bean.
**/
import java.rmi.RemoteException;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.ListResourceBundle;
import javax.ejb.*;
import java.lang.*;
public class MyDeptBean implements EntityBean {
private EntityContext entityContext = null;

public long deptNo = 0;
public String deptName;
public void ejbActivate() throws RemoteException { }
public void ejbCreate(MyDeptKey key) {
ejbCreate(key, "Sales" );
}
public void ejbCreate(MyDeptKey key, String deptName) {
deptNo = key.deptNo;
this.deptName= deptName;

}
public void ejbLoad () throws RemoteException { }
public void ejbPassivate() throws RemoteException { }
public void ejbPostCreate(MyDeptKey key) throws RemoteException {
ejbPostCreate(key, "Sales" );
}
public void ejbPostCreate(MyDeptKey key, String deptName) { }
public void ejbRemove() throws RemoteException { }
public void ejbStore () throws RemoteException { }
public String [] getRecord() {
String s[] = new String[2];
s[0]=""+deptNo;
s[1]=deptName;
return s;
}
public void setEntityContext(EntityContext ctx) throws RemoteException {
entityContext = ctx;
}
public void unsetEntityContext() throws RemoteException {
entityContext = null;
}
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic