Re: How to implement simple DB persistence

tnorgd wrote:
I have a bunch of classes (say, 5-10) that I would like to serialize
into an SQL database. I decided to implement this on my own, because:
- I need to keep control over the data; not all the fields from a
class need to go into DB
- the DB storage format must be easy for humans who are browsing the
DB; there are also scripts in R for data analysis that will read from
the DB
- Stuff like Hibernate is a too heavy gun for it;

My original idea was to add a constructor initialized with SQL
connection, or a pair of static methods for reading from / writing to
a DB into each of my classes. I also plan to use an existing package
to facilitate SQL query building.

In general, I have three goals:
- write my own code that:
- will store the data in the format I need,
- spending as short time on it as necessary

Can you share some advices or some parts of working code for some

Do not reinvent the wheel. While the DB binary formats are not "human-readable", on account of they're optimized for computer use (e.g., CRUD), the existing lightweight databases are robust, largely standards compliant and quite easy to use. Go with Derby (a.k.a. Java DB) - you have it already and it'll save you time, energy and bugs.


Relevant Pages

  • Re: datetime format
    ... I did, I used datetimepicker control, and I get data from SQL Database to ... alternate way is to store date in string format in SQL Database and then get ...
  • Convert Excel Serial Date to SQL datetime
    ... SQL database. ... translate the excel value into a proper datetime format for sql server. ... I don't want to edit the excel file because I have a program that is ...
  • sql dump
    ... I have sql server 2005 express edition installed. ... take a backup of sql database Using the sql management studio, ... in text format.. ...
  • View definition incorrect
    ... I'm using views to update a remote SQL table ... When I change the structure of the SQL table I am forced to update the ... defined within the SQL database as DOUBLE with more than 2 decimal places ... changing the format of the database is a real drag. ...
  • Re: Inserting regional settings specific data into sql server
    ... All EU countries withouth the two English speaking use the format dd-MM-yy ... By using the parameters, while the program is in the right culture setting, ... than all those formats results using SQLparameters in the way the SQL server ...