on 02-19-2007 11:04 AM
Hi Experts,
I have written an EJB Bean Method which returns me a resultset
(java.sql.Resultset) of the records that are selected by the query.
In Web Dynpro i'm calling that method and equating it to a variable of java.sql.ResultSet type.
When I run this project, i'm getting the exception as:
java.io.NotSerializableException: oracle.jdbc.driver.OracleResultSetImpl
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
at com.sap.engine.services.rmi_p4.StubImpl.p4_initializeStreams(StubImpl.java:252)
at com.sap.engine.services.rmi_p4.StubImpl.p4_replicate(StubImpl.java:245)
at com.lti.Src_Dest_Connection.Src_Dest_Connection_Stub.getTblContent4Src_conn1(Src_Dest_Connection_Stub.java:566)
... 34 more
Can anyone help me out with this??
OR
is there any other way to return the resultset to the Dynpro.
Thanx in advance.
Alka.
I finally created a cached rowset and used it for passing the resultset.
Thanx Valery...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alka,
The java.sql.ResultSet implementations are not serializable.
So in general they are not applicable for returning results from EJB tier to UI tier.
This restriction enforced only when you are using remote EJB as opposed to local EJB. Nevertheless, you must avoid returning "native" result sets from EJB methods -- otherwise how it's possible to close associated JDBC statement/connection.
Better approach is to use array/collection of DTO or to use javax.sql.Rowset implementations these are fully disconnected/serializable like WebRowset or CachedRowset.
Valery Silaev
SaM Solutions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Valery,
I've been trying to use javax.sql.RowSet for storing the ResultSet of the query as follows:
String q = "Select * from "+table_name;
javax.sql.RowSet res_rows = null;
ps = src_conn.prepareStatement(q);
res_rs_tbl_cnt = ps.executeQuery();
<b>res_rows =(RowSet)res_rs_tbl_cnt;
OR
res_rows = (RowSet)ps.executeQuery();</b>
but for the above (for both of them) i'm getting a ClassCast Exception.
Can you help me with this....
Thanx in Advance
Alka
Alka,
Please read http://www.onjava.com/pub/a/onjava/2006/06/21/making-most-of-jdbc-with-webrowset.html?page=3 (also I recommend to read entire article). You need extrenal Sun library to make it works. AFAIK, there are 2 javax.sql implemenations for JDK 1.4 -- one from Sun and one from Oracle.
Valery Silaev
SaM Solutions
Post your code
Regards,ANilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anil,
Using Naga Raju's method I've tried adding it to the object of java.util.Arraylist.
This does not raise an exception but even it does not work.
I'm posting the code.. Hoping to find a solution...
<b>CODE FOR EJB METHOD:</b>
public ResultSet getTblContent4Src_conn1(String Selected_Tabl) {
java.sql.ResultSet res_rs_tbl_cnt = null;
java.sql.PreparedStatement ps;
String q = "SELECT * FROM "+Selected_Tabl;
try {
ps = src_conn.prepareStatement(q);
res_rs_tbl_cnt = ps.executeQuery();
} catch (SQLException e) {
e.printStackTrace();
res_rs_tbl_cnt = null;
}
return res_rs_tbl_cnt ;
}
and I'm calling this function as:
ResultSet rs = null;
<u>rs = rem_bean_2.getTblContent4Src_conn1(tab_name);</u>
the above statement raises the exception.
Thanx in Advance.
Alka.
Message was edited by:
Alka Panday
hai,
ResultSet is not seruializable. so you cannot return the result set .
instead that return the arraylist . in arraylist add the resultSet object
from the dynpro cat it to resukt set again.
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.