[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

java problem with transfer data in ejb(stateless bean)

Asked by hungxadieu in Java Programming Language, Enterprise Java Beans (EJB), Sun Java System Web Server

I have a session bean, and this bean is used to connect to database. I want this bean to transfer a resultset to client, but it can't work. So I think that maybe I can use a class to store data and transfer data but I don't know how to do it. Hope someone help me figure out this. This is my code:

///////////////////////EJB object
package Stateless;

import java.rmi.Remote;
import java.rmi.RemoteException;
import javax.ejb.*;

public interface ejbStateless extends EJBObject,Remote
{
      public String sayHi() throws RemoteException;
      public myOwn saveInfo(int a,int b) throws RemoteException;
}

////////////////EJB home
package Stateless;

import java.rmi.Remote;
import java.rmi.RemoteException;
import javax.ejb.*;

public interface ejbStateless extends EJBObject,Remote
{
      public String sayHi() throws RemoteException;
      public myOwn saveInfo(int a,int b) throws RemoteException;
}

/////////////////EJB bean
package Stateless;

import java.util.*;
import java.rmi.*;
import javax.ejb.*;

public class ejbStatelessBean implements SessionBean
{
      private SessionContext ctx;
      public void ejbCreate()
      {
            System.out.println ("ejb create");
      }
      
      public void ejbPassivate()
      {
            
      }
      public void ejbActivate()
      {
      }
      public void ejbRemove()
      {
            System.out.println ("ejb remove");
      }
      public void setSessionContext(SessionContext ctx)
      {
            this.ctx=ctx;
      }
      public String sayHi() throws RemoteException
      {
            //System.out.println ("Hi");
            return ("Chao ban");
      }
      
      public myOwn saveInfo(int a,int b) throws RemoteException
      {
            myOwn m=new myOwn();
            m.a=a;
            m.b=b;
            return m;
      }
      
}

////////////////////EJB Client
package Stateless;

import javax.naming.*;
import javax.rmi.*;
import java.rmi.*;
import java.util.Properties;

public class ejbStatelessClient
{
      public static void main(String arg[])
      {
            String say;
            System.out.println("\n Begin StatelessSession HelloClient Demo...\n");
            try
            {
                  Context ctx=new InitialContext();
                  Object objref=ctx.lookup("java:comp/env/Hello");
                  ejbStatelessHome home=(ejbStatelessHome)PortableRemoteObject.narrow(objref,ejbStatelessHome.class);
                  System.out.println ("Create ejbStateless Client\n");
                  ejbStateless ejb1=home.create();
                  say=ejb1.sayHi();
                  myOwn m=new myOwn();
                  m=ejb1.saveInfo(1,3);
                  System.out.println (m.a);
                  System.out.println (m.b);
                  System.out.println (say);
            }
            catch(Exception e)
            {
                  System.out.println (e.getMessage());
            }
            System.out.println ("\n End StatelessSession ");
      }
}
 
Loading Advertisement...
 
[+][-]12/16/06 07:16 PM, ID: 18153659Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Java Programming Language, Enterprise Java Beans (EJB), Sun Java System Web Server
Sign Up Now!
Solution Provided By: jaggernat
Participating Experts: 5
Solution Grade: A
 
[+][-]12/16/06 10:16 PM, ID: 18153993Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]01/13/07 10:00 PM, ID: 18310980Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/06/07 05:04 AM, ID: 18661148Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03/08/07 12:00 AM, ID: 18677136Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03/08/07 12:34 AM, ID: 18677242Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/26/07 09:03 AM, ID: 18793797Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03/26/07 09:13 AM, ID: 18793868Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/08/07 12:48 PM, ID: 19441086Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07/13/07 09:28 PM, ID: 19485804Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93