I’m far to be an expert and i’ve never claimed to be one.
I’m quite comfortable with java but not with many of its technologies, including JDBC (and servlets also, and many others)… But that’s why we are here, isn’t it?
I’m sorry you felt like i was arguing with previous posts. That’s not what i wanted. And i thank all you forum people to advice me (and others!).
I know my post looked like justifications, hmm, no, they are in a certain way. But, instead of arguing, let me explain more closely why i choosed to access a database directly. It’s not only a matter of easyness.
First: the role of the server or database.
The only meaning of it’s existance is to redirect people to game hosts. More precisely, it stores a list of host IPs and gives them to whoever wants to join.
That’s why the simple idea of a database came into my mind. It’s just an IP pool, nothing else.
Ok, well, i could use a servlet to give back the IP list, and when you join it then flows through the servlet again to inform the database. But i don’t see why it’s more interesting.
As i was “designing” the “server”, i first thought of a servlet that stored all informations Applet<->Servlet. (And it was pretty complicated in fact). Then, i thought that the best way to store the data was a DB. Applet<-Servlet->DB. And a small time after, i wondered why not shortcutting the servlet and accessing directly the DB. Applet<->DB. This solution seemed to simplifies extremely everything and to be… well… a more direct approach. After all, the only thing the servlet had to to was to act as a pipeline, so why not accessing the source directly?
Then arises security problems. This topic can be discussed during several pages, surely without conclusion. Nevertheless, 3 reasons brings me to think it’s ok:
- i’m not a guru nor a security champion but that the DB is accessed through an applet and not from a servlet shoudn’t change much. You’re saying the DB isn’t safe, going through a servlet won’t change this!
- what additional protection can you perform on a DB than username/password? Or how can you protect them better in the compiled code?
- i remind you of the irrelevant informations contained in the DB and the fact that i’m an amateur. I’m not going to protect a DB for the NASA after all! (hopefully for them!;-))
Now, you are pointing to a scalability problem…
Before we start this topic, i’ll explain the program architeture.
The app works on a peer-to-peer basis (where the server or DB should only act as an IP pool to redirect people as discribed before)
Since i’m working with RMI, every class involving distant communication needs to have an interface. So different implementations (or versions) can work nicely together since the interface they are refering to remains the same.
Like thise, I don’t see scalability on the client side as a big problem.
On the server side, the BD stores host IPs, game sort and maybe few other infos. When a person wants to act as host, the applet adds a record in the databases. When it wants to join a game, he recieve the list of games(hosts) available and connect to one of those. When the game ended, the record is erased.
Also here, the DB can be extended without many problems. Fields can be added without affecting client’s requests. The only problem would happen if it explodes of records, but i don’t think it’ll ever be so full of people!
And when not using a servlet, i save the time of not needing to change it each time a change is done to the DB.
Before someones points out the detail that disconnected games could stay in the DB, let me say that a servlet will parse the DB looking for disconnected hosts and delete these obsolete records.
I hope this brings light in the discussion. (And don’t forget it’s not targeted for a nuclear facility!)
After all this trouble, what i’m searching for remains the same: a simple java example opening a database lying on the web. If anyone is able to do this, it would be very appreciated.
Have a nice day!
Thanks for all