Pages

Tuesday, January 31, 2012

Read from JSON file and persist into MySQL

Here is a simple example where we are reading contents of a JSON file and inserting into MySQL database. The code is dynamic so it can handle any number of columns no matter what the column name is. All you have to do is match the database column names with JSON content.



For this demo, we are using following jar files.




And this the content of json file(test.json) we have.



And here is what you see in database after executing above code.

4 comments:

  1. Replies
    1. Do you know of any libraries that can do this?

      Delete
  2. Hello,

    I am a new student in the computer are field and I have been trying to use this code to convert my JSON big data file into MySQL. I already put the code in Eclipse and import those jar files. Could you please guide the way to execute this code in MySQL Command Line? Thanks so much and I am looking forward to hear from you.

    ReplyDelete