| Author |
Writer/BufferedWriter/Reader and MySQL Database.
|
anoop jozi
Greenhorn
Joined: May 22, 2012
Posts: 2
|
|
Hello:
I am intend to use a third party library for my application. The library provides facilities for reading and writing data ( a graph) into and out of files.
The function signatures ( the api) to do this is :
Writing to a file.
-----------------------
protected void writeEdgeData(Hypergraph<V,E> g, Writer w)
protected void writeVertexData(Hypergraph<V,E> graph, BufferedWriter w)
Reading from a file
--------------------------
void load(Reader reader, G g)
// Populates the specified graph with the data parsed from the reader.
void load(String filename, G g)
//Populates the specified graph with the data parsed from the specified file.
------------------------------------------------------------------------------------------------
My need is that I need to save these objects (HyperGraph<V,E> g) in the "writing to file" section above. , to a MySQL Database.
Alternatively I would like to read the stored file in the database and get back the Graph object (G g) in the "Reading from a file " section above,
How can I achieve this storage and retrieval of graph objects to and from a MySQL database given the API above.?
THanks
|
 |
Martin Vajsar
Bartender
Joined: Aug 22, 2010
Posts: 2328
|
|
Welcome to the Ranch!
It seems that your data would ideally be stored in a database as a CLOB field.
You might use a StringWriter, for example, to write the graph into a memory structure and then use standard JDBC methods to write the resulting String into a CLOB field. Loading the data from the database would reverse the process - obtain the data as a String, create a StringReader from that String and pass it to the load() method.
There are many examples of reading/writing CLOBs on this forum as well as on the internet, but of course, if you get stuck, we can help you if you show us what you've done.
|
 |
anoop jozi
Greenhorn
Joined: May 22, 2012
Posts: 2
|
|
Dear Martin:
Thank you for your advice.
|
 |
Martin Vajsar
Bartender
Joined: Aug 22, 2010
Posts: 2328
|
|
You're welcome!
|
 |
 |
|
|
subject: Writer/BufferedWriter/Reader and MySQL Database.
|
|
|