How to return a ResultSet from an BeanManaged Entity Bean


EJB programming & troubleshooting: How to return a ResultSet from an BeanManaged Entity Bean

  1. Hi,
       By my question u can get it what i am expecting.....
       Ya i would like to return an Resultset object using my own getXXX method from a Bean into some Client App so that i can retireve it through a resultset object in my client application.........

    Thanks in Advance...
  2. hello
    the method return type make as ResultSet object
    and in the method code last line return the resultset object
  3. Hi Sudhir,
       Thanks for ur Reply,But Boss I already tried the same method.Hey Take my words(Mantra......)
       " U can pass data only through Primitive Types"

      Ok,I tryed with Resultset returning through a method and YES it is possible if it is Local Program.BUT IF IT IS ON A REMOTE viz... RMIs,EJBs there will be problem while MARSHALLING and UNMARSHALLING thats what i already Faced......
        So i need some other solution if u have any PL let me know.....

       But Anyhow Thanks for ur reply....

  4. That's because a ResultSet is not a serializable object. You have to either convert it to a collection object or use something like CachedRowSet... I never done the second option but there are 100 different threads on that address this very same issue...

  5. I have done with how to pass result set to the client in the session bean. But for the Entity, my question is why you want to pass a result set.

    However if you want to pass a result set to the client, here is the code wich I have implemented and it is worked fine:
    This method is implemented in the bean class:

        public CachedRowSet getAllRecs() throws Exception {
    CachedRowSet crs=new CachedRowSet();
    String sql_query="SELECT Ccy,CcyNm FROM "+
    " ORDER BY Ccy";
    Statement stmt=instrum_connection.createStatement();
    ResultSet rs=stmt.executeQuery(sql_query);
          catch (Exception e)
    System.err.println("getAllRec function"+e.toString());
    return crs;
    To this: you must download the rowset.jar file from and set it to your class path of the application server and your client machine.

    Any more question about this you mail for me at: lddoan99 at yahoo dot com

    Hope this will help.