Hi, my name is John.I am registered user of javaranch.com I am facing a problem of RMI Object Serialization.From a server program I want to pass an Object as a parameter but I can't serialize the object.Plz help me.Send me a good material on Object Serialization.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); c=DriverManager.getConnection("Jdbc dbc:EBANKING","db2admin","db2admin"); s=c.createStatement(); r=s.executeQuery("SELECT * from CURRENTAC,BRANCH where CURRENTAC.BRANCHID=BRANCH.BRANCHID AND CURRENTAC.CUSTOMERID='" +s2+ "'");
Here's the problem... ResultSet isn't serializable, so you can't return it from your remote method. You'll need to do something like this for it to work -
Make a class that implements Serializable. Have a field in this class for each column you are concerned with in the tables that you are querying with JDBC.
Inside the display() method, you'll need to get the ResultSet. Then create a Serializable Collection - like an ArrayList. Loop through the ResultSet. Each time through the loop create a new object of the class you have created above and set it's values from the ResultSet. Add your new object to the ArrayList.
Once you are done looping through the ResultSet, return the ArrayList - it contains all the data from your query in the form of objects of the class you have created.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.