Add fully operational database method

The memory problem last time is that I confused new() with new[]. Now it
is fixed.