Jump to content
  • Advertisement
Sign in to follow this  
menyo

Database for Java?

This topic is 1317 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

 

I am building a client/server based android game with LibGDX and Kryonet extension. The server will only be run in desktop mode, maybe i'll even setup the server completely loose from libGDX/android if that is possible with Kryonet. Anyway, i'm looking and weighing my options for a system to track player data, from login credentials to message logs and collections to player status.

 

Only the server side will communicate with the database directly. Kryonet supports http requests so i could setup a PHP script that communicates with the database and posts back data. But there must be a better more direct way I think. Is it possible to setup somekind of DB and sent/receive queries directly to/from the database.

 

 - Plus points if this works with libgdx, since i have my server side working already in the LibGDX environment i would prefer to do it this way.

 - I have a lot of experience with MySQL, so a SQL based solution is probably better. I don't know how much other DB's defer from SQL though.

 

Any input is welcome, if you think it would be common sense to just write binary data to disk to store stuff then say so. It is my first client/server game and i want to make it a success, just this storing of data gives me headaches.

Share this post


Link to post
Share on other sites
Advertisement

Well, instead of a PHP script, you can communicate to the database with... Java DBC. As your server is already in Java, just implement the database access in Java instead of adding the additional overhead of calling a PHP api and so, it'll be easier and faster. Also, there are some libraries and frameworks to make your life easier (I'd recommend ActiveJDBC, but you can find some more through Google). Also, you can use MySQL or whatever database you prefer, so no problem with that.

 

I don't understand what do you mean by "LibGDX environment", but I don't think LibGDX has any integrated solution to access databases, but probably someone developed a third party solution, so it's worth to check.

Share this post


Link to post
Share on other sites

Well, currently my server runs in a LibGDX framework/environment. I will just use the exe/jar from the desktop project to run the server so I do not expect to run into problems. But since there is no need to run the server from a android device I could probably ditch LibGDX and just use Java with Kryonet and add a DB extension to the mix to keep the server project clean.

Share this post


Link to post
Share on other sites

Okay, I misunderstood this:

 

"Is it possible to setup somekind of DB and sent/receive queries directly to/from the database."

Share this post


Link to post
Share on other sites

Okay, I misunderstood this:

 

"Is it possible to setup somekind of DB and sent/receive queries directly to/from the database."

 

Yeah, what i meant was without weaving in a php script through a http request. So directly, but from the server side.

Share this post


Link to post
Share on other sites

If you want a lightweight SQL solution then JDBC is the way to go.

If you like JDBC but don't like how tedious it is to use then look at the Spring framework's JDBCTemplate module, which fits exactly that purpose.

If you want to move away from SQL and towards ORM (Object-relational mapping) then looks into JPA and/or Hibernate.

 

As for databases themselves, any will do, including MySQL if that's what you're comfortable with.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!