Yeah you have to return an arraylist or a vector, i.e something that is
serializable. It is never a good idea to pass ResultSet objects around.
Although it is attractive in terms of changeability (eg adding more fields
etc) to use a ResultSet, it can become a nightmare when there are network
problems and you can leak connections if you don't handle the exceptions
properly.

If you are using ejb's then the whole idea is that the EJB is an object
version of the data so that you can work directly with the object. If you
want to use a ResultSet directly in the jsp (useful for reporting etc), just
open the connection to the database directly in the JSP and do your query
and close it again. If you are doing something more invovled you might want
to user a few beans/taglibs (there are some nice jdbc ones around) just to
stop your jsp pages from becomming a spiderweb.

Your DBManagerBean looks dangerous - there is a pretty good chance you are
going to leak connections. Rather use just a normal bean that you can
instatiate locally at the jsp side or the ejb side. Thus there is no need to
use an ejb to control connections.

Regards,
Manuel

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Andres Garcia
Hourcade
Sent: Wednesday, November 21, 2001 3:32 AM
To: Orion-Interest
Subject: OrionRemoteException: Error (de-)serializing object:


Hi, i am new in J2EE technology and i'm big troubles.

I have an intranet application (jsp & ejb) running fine with version 1.4.0,
i am trying to deploy the same EAR in 1.5.2 version, but i get this error.

com.evermind.server.rmi.OrionRemoteException: Error (de-)serializing object:
org.gjt.mm.mysql.jdbc2.ResultSet; nested exception is:
java.io.NotSerializableException: org.gjt.mm.mysql.jdbc2.ResultSet

This error occurs when i return a ResultSet from a method "executeQuery" of
an EJB that manages de mysql db.

I have written many jsp, that are in production, and i woud not want to
modify them.
Is there any solution for this error ?
Can i solve this problem if i return a Vector, instead of a ResultSet ?

Many thanks in advance and best regards

Andres Garcia Hourcade

====================================
EJB
====================================
import java.rmi.*;
import java.util.*;

import javax.ejb.*;
import javax.naming.*;

import java.sql.*;
import javax.sql.*;
import javax.sql.DataSource;

// ejb que maneja archivos de log
import Log.*;

public class DbManagerBean implements SessionBean
{

   transient SessionContext context;
   transient Connection conn = null;
   transient DataSource ds = null;
   transient Statement st = null;
   transient ResultSet rs = null;

   public void getConnection(String datasource) throws RemoteException,
DbManagerException
   {
      try
      {
         InitialContext ictx = new InitialContext();
         this.ds = (DataSource) ictx.lookup(datasource);
         this.conn = this.ds.getConnection();
      }
      catch (Exception e)
      {
         throw new DbManagerException(e);
      }
   }


   public void closeConnection() throws RemoteException, DbManagerException
   {
      try
      {
         this.conn.close();
      }
      catch (Exception e)
      {
         throw new DbManagerException(e);
      }
   }

   public ResultSet executeQuery(String strsql, String logonuser) throws
RemoteException, DbManagerException
   {
      st = null;
      rs = null;
      try
      {
         //ResultSet.TYPE_SCROLL_INSENSITIVE,
         //ResultSet.CONCUR_READ_ONLY
         this.st = this.conn.createStatement();
         try{
           // logeo la consulta
           InitialContext context = new InitialContext();
           LogHome logHome = (LogHome)
javax.rmi.PortableRemoteObject.narrow(context.lookup("Log"), LogHome.class);
           Log log = logHome.create();
           log.writeDebug(strsql, logonuser);
           log.remove();
         }
         catch (Exception e)
         {
            throw new DbManagerException(e);
         }
         rs = this.st.executeQuery(strsql);
         // the closing of a statement also closes all
         // the resultsets asociated with the statement
         st.close();
      }
      catch (SQLException e)
      {
         throw new DbManagerException(e, this.conn);
      }
      return (rs);
   }

   public void ejbPassivate(){
       context = null;
       conn = null;
       ds = null;
       st = null;
       rs = null;
   }

   public void ejbActivate()
   {
   }

   public void ejbRemove()
   {

   }

   public void ejbCreate()
   {

   }

   public void setSessionContext(SessionContext context)
   {
      this.context = context;
   }

}



Reply via email to