I'm trying to work with db4o just getting familiar with storing and receiving values. My file path pointing to the file is correct and there are no syntax errors. I'm just wondering why this is the output I get from the console when I run the program (I built a simple Contacts class as well):
Stored Contact@289d1c02
[Contact@289d1c02]
How can I retrieve the values instead of the memory address?
public static void main(String[] args) throws Throwable{
Contact contact1 = new Contact("Bob", "01/01/01");
ObjectContainer db = Db4oEmbedded.openFile(Db4oEmbedded.newConfiguration(), DB4OFILENAME);
try {
db.store(contact1);
System.out.println("Stored " + contact1);
List <Contact> contacts = db.query(Contact.class);
System.out.println(contacts);
}
finally {
db.close();
}
}
To retrieve the actual values, you'll have to override the Java's native java.lang.Object.toString() method in the Contact class.
This will allow you to display an actual message with information about each object rather than the memory address.