This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writer/BufferedWriter/Reader and MySQL Database.

 
anoop jozi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 3751
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Martin:

Thank you for your advice.

 
Martin Vajsar
Sheriff
Pie
Posts: 3751
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic