hii, i am writing a application, in which i have to transfer resultset from server to client to display data from database, how can i do that, if i m trying to return resulset directly it showing me an exception.
do i need to serialize it, if yes then how??
here is part of my code:
Client Part where i am fetching:
Part of the exception
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.mysql.jdbc.JDBC4ResultSet
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at ImplementClass_Stub.displayData(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
how do i solve this..?
is it possible, create a bean class and return the object? if yes than how??
okay, i have done this, my values are displaying.
one thing i want to ask.
i have also added a next button to my frame, initially all my text fields showing first record from my db, what i want is when i click on next it should show me second record then third and so on, how can i do this??
in case of resultset, i can directly fetch resultset.next(), but how to do this with arraylist??
here is what i m doinf for displayin first record initially(when i run client.java).
this is the code which displaying 1st record from the database(when i click next), but i want it should display next record and so on...
how can i do this?
Punit Jain wrote:but i don't want to execute query again and again, my all data is in array list, if i am printing that on my system whole data is printing but i want, one by one record when i click next.
Your desires are good and well founded. But you are asking the wrong question. which is causing you to chase for solutions that can't exist.
You can't serialize the ResultSet, so don't do that. And thus RMI is not your solution.
Write a server-side process (servlet, bean, etc.) that your client talks to. Pass messages using REST or similar simple, easy to debug protocol.
Have one message be "do the following select for me" which will return a nonce. and the first few rows of data, in CSV, JSON, etc.
Have the client then say "here is the nonce, get the next 20 rows"
repeat until done.
Joined: Aug 20, 2011
yes i m doing something like this, i have created a bean class, and returning values from database in arraylist and returning that arraylist, and on the client side i am fetching that list and displaying records, but how do i fetch next records from that??
here is what i am doing:
client.java (part of code):
this is showing first record from the arraylist, but i want on each click it should show next record.
Joined: Nov 24, 2011
you have done mistake in preparing list of BookBean.
The return type of display method should be List<BookBean>.
Keep your BookBean as separate class and have your display() method in separate class
public List<BookBean> display()
Connection conn = DriverManager.getConnection(url,user,pass);
Statement st = conn.createStatement();
rs = st.executeQuery("SELECT * FROM books");
List<BookBean> aa = new ArrayList<BookBean>();
BookBean book=new BookBean();