Solved

how do client get data packet returned from EJB method (public List getResultset(String sql)) ?

Posted on 2003-11-23
6
489 Views
Last Modified: 2013-11-24
Hi,
  where I define one method in Entity bean which return query result,I test it in Entity bean body,it can get right return.But from client ,I can not get returned data. What is the reason for that?
java.lang.NullPointerException

      void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)

            RMIConnection.java:1558

      java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])

            RMIConnection.java:1511

      java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])

            RemoteInvocationHandler.java:55

      java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])

            RecoverableRemoteInvocationHandler.java:22

      java.util.List __Proxy1.getResultset(java.lang.String)

      void Samplebbs_live.Tb_userClient.main(java.lang.String[])

            Tb_userClient.java:84

  Entity Bean:
  public List getResultset(String sql)
  {
   List list = new ArrayList();      
    try
   {
    dbconn = getConnection();
    st = dbconn.createStatement();
    rs = st.executeQuery(sql);
    ResultSetMetaData mtdata = rs.getMetaData();
    if (rs==null)
    {
      System.out.println("null data");
      return Collections.EMPTY_LIST;      
    }      
    int col = mtdata.getColumnCount();
    while (rs.next())
    {
       map = new HashMap(col);
       for (int i=1;i<=col;i++)
       {
           map.put(mtdata.getColumnName(i),rs.getString(i));                
       }
       list.add(map);
    }
    dbclose(st,rs,dbconn);
    for (int j=0;j<list.size();j++)
   {
     Map m = new HashMap(col);
     m = (Map)list.get(j);
     System.out.println(j);
     System.out.println((String)m.get("mailaddr"));
   }
   }

   catch (Exception se)
   {
     se.printStackTrace();
     return Collections.EMPTY_LIST;
   }   System.out.println("4");
    return list;
  }
but when I called it from client by the following way:
...............
      List lt = new ArrayList();
      lt = tb_user.getResultset("select * from tb_user");    ---error here
     //tb_user ---EJB Object
..............
0
Comment
Question by:hexiaoquan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 9809290
 Can you do a System.out.println(list) in your EJB before this line: return list; and tell us the output?
0
 
LVL 35

Expert Comment

by:girionis
ID: 9809297
 Also look at the server console/logs for any possible exceptions.
0
 

Author Comment

by:hexiaoquan
ID: 9809357
Yeah,I can get System.out.println(List) in EJB

  for (int j=0;j<list.size();j++)
   {
     Map m = new HashMap(col);
     m = (Map)list.get(j);
     System.out.println(j);
     System.out.println((String)m.get("mailaddr"));
   }

 It can run well.
Now I get the right answer,Return value Type shout implements java.io.Serializable,
but list do not implement it.so I change it to Vector or rowset.It is ok now

thanks.
0
 
LVL 35

Expert Comment

by:girionis
ID: 9809361
 Ah... yes true, the object should implement serializable if you want to return it...

  Please ask a question here http://www.experts-exchange.com/Community_Support/ for zero points to PAQ the question and refund the points to you.
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 11688317
Submitted to PAQ with points refunded (50)

DarthMod
Community Support Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hibernate jars 4 57
Java Restore security prompts not working 10 123
Cisco ASA: Java web start no go, asdm launcher no go 3 57
IntelliJ and Eclipse Neon 2 installations 4 33
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question