1

i had created a java project which is getting a resultset from mysql and i have to store my resultset into a hdf5 file, so how to do it properly?

Right now i am getting the data from sql in resultset and than storing it into List of Map and than converting it to byte array, storing that byte arry to hdf5 file. (because hdf5 support dimensional data only)

IHDF5Writer writer = HDF5Factory.open("farray.h5");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(data);                           // data is my List of Map variable
    byte[] bytes = bos.toByteArray();
writer.writeByteArray("mydata", bytes);
writer.close();

And this storing my data to the hdf5 file but this not seems to be better approach, so is there is any better way to store the resultset into the hdf5 file? sorry for English and Grammar

user3458271
  • 638
  • 12
  • 31
  • What is your definition of "better" in this situation? How is one solution "better" or "worst" compared to other solutions? What are your requirements for the stored data? It sounds like it's a normal serialization problem, which you have already solved. – Progman Feb 20 '19 at 12:08
  • okhy right now as how i am saving data is in byte array format so they are not visible as normal data in hdf5View because it is in byte array format, so i have to store them in the way so i can view them in the hdf5View as normal data table. – user3458271 Feb 21 '19 at 05:00
  • You can use the other `write*()` methods to write different values with different keys. You might even use dynamic key values which represent somehow your original result set like "mydata_row_4_column_email", but then you need to search/find your keys back, when you want to read the "table" data. – Progman Feb 21 '19 at 17:49

0 Answers0