I have Java Map (out of Strings and Ints) objects that I want to save to a database. Is there a standard way to go about this task? Is there a way to compress the Map to take less space on the harddrive?
+4
A:
You actually ask two different questions:
- How to save a Map object to a database
You need to create a database and an appropriate table. You can of source serialize the Map into a binary object and store that in the database as a BLOB. It will be better however to have a table entry for every object in the map. You need to use the JDBC API to communicate with the database.
- How to compress the Mao to take less space in the hard drive?
You need to serialize the Map to a file. The map will be saved in a binary file, which you can try to compress.
kgiannakakis
2010-04-12 10:23:51