Solved

SQL ResultSet NotSerializableException

Posted on 1997-05-08
5
327 Views
Last Modified: 2008-02-26
I got this exception while trying to pass a ResultSet object by rmi. My version of JDK is 1.0.2 and I have the last rmi version for JDK 1.0.2.

This is the execption -->

rmiClient exception: Error unmarshaling return; nested exception is:
        java.io.WriteAbortedException: Writing aborted by exception; java.io.Not
SerializableException: sun.jdbc.odbc.JdbcOdbcResultSet
java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
        java.io.WriteAbortedException: Writing aborted by exception; java.io.Not
SerializableException: sun.jdbc.odbc.JdbcOdbcResultSet
        at domtar.server.rmiServer_Stub.getResultSet(rmiServer_Stub.java:65)
        at domtar.client.rmiClient.getResultSet(rmiClient.java:57)
        at Client.executeQuery(Client.java:258)
        at Client.start(Client.java:247)
        at sun.applet.AppletPanel.run(AppletPanel.java:271)
        at java.lang.Thread.run(Thread.java:294)
java.lang.NullPointerException
        at Client.fillGridSecteur(Client.java:309)
        at Client.executeQuery(Client.java:260)
        at Client.start(Client.java:247)
        at sun.applet.AppletPanel.run(AppletPanel.java:271)
        at java.lang.Thread.run(Thread.java:294)
0
Comment
Question by:pjroy
5 Comments
 
LVL 1

Expert Comment

by:mlimotte
ID: 1220257
I believe that the ResultSet object keeps an open cursor to the database.  It does not load in the complete contents of the query, and therefore, can not be serialized (all the data is not available).  

As a work around, try loading all the data into a common data structure (an array or vector).
0
 
LVL 1

Expert Comment

by:mlimotte
ID: 1220258
I believe that the ResultSet object keeps an open cursor to the database.  It does not load in the complete contents of the query, and therefore, can not be serialized (all the data is not available).  

As a work around, try loading all the data into a common data structure (an array or vector).
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1220259
For what its worth, marshaling is the proces by which the client and server guarantee that data is being transfered in a safe and compatible manner.

An unmarhaling exeption is usualy cast when when you have IDL level incompatibilities between the client and the server. (integer size for exaple).

In DB oriented apps, it can also be cast when you bind local variables to SQL columns that do not match. (Java 2-byte chars to SQL 1 byte chars for instance.)

Now if the error is actualy related to the serialization process (and is not appearing as a side effect of an IDL definition error). Than Java is trying to serialize a value of one data type but actualy obtaining a value of another.

Hope this helps to gain an insight into the problem.
0
 

Accepted Solution

by:
rkin005 earned 0 total points
ID: 1220260
Well, the class ResultSet doesn't implement the interface
Serializable.  Therefore you can't pass it thru RMI.

0
 

Expert Comment

by:exprd
ID: 2205006
Since the Resultset is not serialiazable, it looses it's state while been transfered from server to client. So, put the values from resultset to a vector since u don't know the size of the resultset , vector is recomended, and send.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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…
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

912 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now