Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

what backend should be used?

831550May 15 2011 — edited May 16 2011
well i m developing a card game in java.
i would like to know for saving the game settings like the cards and variables of the game what backend should i use. i want the application to be fully platform independent and also dont want to use any proprietory s/w like ms access.

should i store it in a txt/dat file or is there any such compatible db; not talking abt full fledged server kinda dbms like oracle or sql server. just a basic dbms s/w for a small need like this.
thanx

Comments

JDScoot
It really depends on the scope of the game. Will this be played on the web by many people at a time? Or is this more of a single player desktop app?

For a dbms MySQL is a free, easy to install and light weight solution. This is my usual go-to light weight dbms.

Outside of a database, one option is to serialize the objects that contain the states in which you want to save such as player info, card in players hand, and cards in the deck. You just need to make sure those classes implement the Serializable Interface. When the player saves or exits the game, the objects will be serialized saving their state. When the player is ready to start the game again you can deserialize those objects back into java objects on the stack with the same state they had when they were serialized.

Take a look at the "Serializable" class on the documentation page here [url http://download.oracle.com/javase/6/docs/api/index.html]http://download.oracle.com/javase/6/docs/api/index.html. It is in the Java.io package.

If you want a Java based DB that is super light wait (very little functionality), can be distributed with your game app, and completely platform independent you can take a look at SmallSQL [url http://www.smallsql.de/]http://www.smallsql.de/. I have not used this one myself but it might do the job you are looking for as well.

Again, choosing between a DB and data file/serialized objects as well as choosing which DB you should use will depend on the scope of the game. If you are hosting the game, a DB like MySQL will work great. If it is a desktop app than serialization of object or distributing the SmallSQL java DB with you app might be the better choice.

Edited by: JDScoot on May 15, 2011 12:05 PM
YoungWinston
aLkeshP wrote:
should i store it in a txt/dat file or is there any such compatible db; not talking abt full fledged server kinda dbms like oracle or sql server. just a basic dbms s/w for a small need like this.
Txt is obviously quite a bit simpler. One method is to store the steps that got you to the current situation (this is what a lot of chess programs do).

The advantages of that approach are
(a) You don't have to store a lot of "state" (except, in your case, probably the original shuffled deck).
(b) You can log the steps as you play.
(c) Your 'resume' code can resuse practically all of your existing code (in fact it's just a special case of a regular game).

Winston
jduprez
i would like to know for saving the game settings like the cards and variables of the game what backend should i use
If you want to save "settings" (configuration) as opposed to "data" (the results, or sates, of a game), then you also have the Preferences API.
It is cross-platform, and has built-in scoping (per-user preferences and global preferences).

See http://download.oracle.com/javase/6/docs/technotes/guides/preferences/overview.html
862113
.. or you could use JavaDB which is installed with JDK. It can be embeddable in applications (w/o running dedicated db server). More information http://www.oracle.com/technetwork/java/javadb/overview/index.html
1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 13 2011
Added on May 15 2011
4 comments
156 views