richardsimnett
asked on
Writing a Hashtable to a socket
Hello,
I need to know how to write and read hashtables passed over a socket connection. The program basically takes data from a database, converts each row to a hashtable and then needs to connect to several servers, and pipe this information to them. A hashtable for me is the easiest way to do this. Can someone show me how to accomplish this?
Worth 500 points.
Thanks,
Rick
I need to know how to write and read hashtables passed over a socket connection. The program basically takes data from a database, converts each row to a hashtable and then needs to connect to several servers, and pipe this information to them. A hashtable for me is the easiest way to do this. Can someone show me how to accomplish this?
Worth 500 points.
Thanks,
Rick
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use ObjectInputStream/ObjectOu tputStream
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
JAlmanaac on Serializing and Unserializing an object:
http://javaalmanac.com/egs/java.io/SerializeObj.html
Pretty much exactly what objects said. But the site is a great reference if you did not know about it.
Joe P
http://javaalmanac.com/egs/java.io/SerializeObj.html
Pretty much exactly what objects said. But the site is a great reference if you did not know about it.
Joe P
Another approach is to use RMI and it will handle the job of creating sockets/ threads, serializing/ deserializing objects for you. Make sure the object (message) definition is available on both sides (meaning the class whose instances you are putting in the hash-table).
I just gotta ask somebody.
Is it me or does the java API look like they are using some CSS and Images now?
I expect both of you have looked at that site tons of times, doesn't it look different! Maybe its just me
Is it me or does the java API look like they are using some CSS and Images now?
I expect both of you have looked at that site tons of times, doesn't it look different! Maybe its just me
You mean the Java TA here or the Java API doc on Sun's site?
Java API, but I was wrong, I was just on the SerializedForm screen, I had never been on it before and there was just a lot of big text and colors... Normal classes are normal, I was just on a weird page.
Joe P
Joe P
ASKER
objects,
Im not familiar with serializable, the keys and values are strings across the board.
Thanks,
Rick
Im not familiar with serializable, the keys and values are strings across the board.
Thanks,
Rick
ASKER
can you give me an example of what this would look like so I can familiarize myself with it?
Thanks,
Rick
Thanks,
Rick
ASKER
nevermind I got it now... Strings are serializable, and that just adds methods that are in place to read / write them.
Im going to split points.
Thank,
Rick
Im going to split points.
Thank,
Rick
>> Im not familiar with serializable, the keys and values are strings across the board.
Primitive data types and many standard Java classes are serializable by default. If that's what you use in your own class, you should be fine
Primitive data types and many standard Java classes are serializable by default. If that's what you use in your own class, you should be fine