I have a client and a server - the client sends the server a message, and depending on what message is sent, the server will perform an action and then reply to the client.

Most of the actions that I have implemented are working.

I need help with one of the actions though - The client will send the server a request.

The server has to query a database and then return the results to the client.

Is it possible to send a resultset from the server to the client?

If so, what function will I use, and if not, what is the best way to send the information back to the client?

Recommended Answers

All 3 Replies

You can use an ObjectOutputStrem / ObjectInputStream via you sockets to send a set of results. If all the calsses & subclasses are serialisable that simply works. If not, extract the data into something that is serialisable and send those.

A ResultSet is tied to a Statement which is tied to a Connection. If you close the Statement or Connection, you impact the ResultSet. It is ideal to take the ResultSet on the server and place it into a different object and then pass that new object to the client. This lets the server quickly free up the database resources for the next action/query.

You may want to look at DynaBeans (Apache project)

Thanks all for replying, will try these today.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.