• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Resultset over an output/input stream

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 26777
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:


 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

Fixed that..the



should have been commented but was not...

Thanks,

Bil
 
No more fooling around. Read this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic