I am assuming that by "Magic Cookie" you mean something similar to the identifying code that is on the front of a Java class file. When the JVM reads a class file it reads the first few bytes and looks for a specific pattern which has the hexadecimal value "CAFEBABE". Here is a pseudo program that does that:
If you "run" the above pseudo program on a java class file, say ReadMagic.class, you will get the output "Looks like a class file".
I leave you to fill in the missing details
You can then modify your program to read your database file and print out the "magic cookie" at the front of it.