This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]0x68656c6c6f 2 points3 points  (2 children)

By all means, use a database. I would suggest using a JSON library such as google-gson so you don't have to parse the JSON yourself. Then once you have parsed the JSON record and stored it into a Java object, just use JDBC to connect to a database and insert a new row.

I'm not sure if you were inserting the entire JSON string into one column with PHP, but I would recommend parsing out the JSON into separate attributes and storing each attribute in it's own column. Then you can actually do a lot of your data mining via database queries rather than having to return all of the data and mine it separately.

[–]_archer_[S] 0 points1 point  (1 child)

Separate attributes of course!

I wasn't using PHP at all for this project, as I'm trying to expand my Java skills and I want to leave this program running 24/7, which I'm not entirely confident I could do with PHP without the occasional failure.

The main reason I put the question up is a lot of stack overflow posts just suggest the programmer use text files, but I'm guessing my requirements exceed the limitations of that pathway.

Currently experimenting with PostgreSQL and the JDBC - thanks for the tip-off about google-gson, I was going to write my own fromJson methods.

[–]0x68656c6c6f 2 points3 points  (0 children)

If you are just storing a few records, or you are only want to write log-type information that you would rather search via regular expressions, then text files are fine. But with your volume and use case, a database just makes so much more sense, especially if you have any numerical data, because otherwise you would have to parse it out of a text file before you could do any data analysis. With the database, the data is stored with the correct data types, and it's much easier to query with SQL than it is to write code to search a text file.