Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Servlets and the fly likes How to access databse from Applet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to access databse from Applet?" Watch "How to access databse from Applet?" New topic

How to access databse from Applet?

Robert Ploch

Joined: Jun 05, 2002
Posts: 19
We have to create a game as JApplet. This Applet should load the levels/tasks from the project-page level by level, not instantly when the game starts.
The Applet should also load Hiscores while loading the game and save them after finishing the game into a database.
The main problem is, that we dont exactly know which technology to use.
We don`t have much experience in databases and connection-based programming, therefore it need`nt be fast. The maximum number of players is estimated about 100 at time.
Could you give me the best option for this problem? We discussed implementing a SQL-DB, which would fit our interests(and retrieving the stats) best.
Or does a better version exist?
With regards
danny liu
Ranch Hand

Joined: Jan 22, 2004
Posts: 185
My option is:
a. build a database component on the server side which connects to DB using JDBC
b. build EJBs that implement business logic via that database component
c. rewrite your applet to utilize the EJBs

Hope it helps.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
EJB are overkill in almost all cases, this being one of them.
I think a fullblown database may be overkill here as well.
Store the levels as flat files which are cached in memory by the serverside process for performance.
Highscores can be stored in either an embedded database or also in a flat file (again, memory caching may be called for).
Create a simple server process communicating with your applet using a TCP/IP socket.
Make it multithreaded (thus you need to make your caching and/or data access code threadsafe).

wally fer

Joined: Apr 28, 2004
Posts: 5
You can
1. have Applet to Servlet communication
2. servlet talks to the database
Have signed applet which directly talks to remote database. (Risky business)
Robert Ploch

Joined: Jun 05, 2002
Posts: 19
Thanks so far for your suggestions.
Is the whole servlet-story difficult to implement? We only have 2-3 weeks time for that, without any experience in database-design ans so on.
It is also very hard to find sourcecode for this adventure, does anybody have some examples?
I agree. Here's the link:
subject: How to access databse from Applet?
It's not a secret anymore!