The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Re: write object to sql db

Yes there is. For my Project we used DatabaseDerby that comes with the NetBeans IDE. First you must connect to the database manually before running the program, then its really easy, its just some repetitive code followed by the statement of what you want to do, like insert, delete etc. Here is a part of my project that did some database executions.

if(addMoneyToAcc == true) //if user pressed "Add Money to Account" button
{
// This line of code creates an instance of the driver for the database
Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
// Connects to the database
myConnection =
DriverManager.getConnection("jdbc:derby://localhost:1527/BillsDatabase",
"root","root");
stmt = myConnection.createStatement();
testQuery="select account_balance from transmitters where transmitter_id=" +
transmitterIDNum;
//above statement creates an SQL string to be executed
results=stmt.executeQuery(testQuery); //executes the query
stmt.close();
results.close();
myConnection.close(); // it is important to do all the closing, otherwise u will get an error
}

So basically you repeat all the code except the part that is the query, that is what actually alters the database, everything else can be copied and pasted. You have to know how to work with database statements.

I checked db4o out and have read the documentation(well up to chapter 5 or so) and I was amazed! This is truly a beautiful object db. And the "Interface"(db.store() and alike) is also very logical what I really like

A database per file wich can go up to 254GB a file and its fast! Its perfect this way its easier for me to back it up. And i'll be using multiple files ofcourse. Users, shop and those stuff will get their own file

I will have records though, this will be pure data(and alot), not objects so I think I'll still be using PostgreSQL wich I regret. This data will be point calculating(adding or reducing points). But maybe you guys have a better solution?