Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Resultset over an output/input stream  RSS feed

 
Billy Green
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I hava an issues with a program i am writing. It is a client/server with a database (3 Tier) The majority of requests are related to SQL Select statements. The purpose is to for instance type in a name on a GUI on the client side and return results relating to that name.

The client and the server are setup and i can communicate when testing using the putln(x)...flush() commands...my headache comes when trying to work out how to get alot of information back to the client...

Would anyone be able to point me in the right direction...

Thanks,

Bil
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write a loop that converts each row that the ResultSet returns into some kind of custom object. Add this object to an ArrayList, so you will end up with a list of some kind of object. Close the ResultSet and send the List back to the client.
 
Billy Green
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

Thanks for the reply, i understand the concept of what i need to do from what you posted but have not been able to find many good examples of what i need to do...

would you be able to point me in the direction of any good documentation.

Thanks,
Bil
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Billy Green:
would you be able to point me in the direction of any good documentation.


You need to look at Trasfer Object/Value Object.
 
Billy Green
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have tried to code this to send a List over a datastream and have got stuck converting the data send back to a list on the client side. Could someone help me out?


I have coded a Client/server to show what i am doing....its messy!

Server:


Client:


 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do I understand correctly this works so far, sending one String each way?

The reason this works is that your streams handle Strings quite naturally but not other objects. To send other objects back & forth you'll need to look up ObjectInputStream, ObjectOutputStream and (if you make your own objects) Serializable.

See if that's enough of a hint. I've had good luck with just about any standard Java class doing Google for "java whatever tutorial". Give it a try and show us what you make!
 
Billy Green
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Stan,

Did what you said and got alot further with my code but seem to have hit a problem...

I will post the code and explain below

Server:


Client:



It seems i send the object to the Client but the line of code:



It wont execute and cannot see why...would someone be able to let me know why this is happening, do not seem to get an exception either?

Thanks...

Bil
 
Billy Green
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

Fixed that..the



should have been commented but was not...

Thanks,

Bil
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!