[Java] Easiest to set up database?

Started by
6 comments, last by janta 17 years, 10 months ago
My head has been spinning because I've procrastinated way too much on a project due by 3pm tomorrow. I need some easy way of saving and loading information with Java. I've looked into ODBC or JDBC with little success as most of it has to do with Microsoft Access which for some reason wasn't included in my XP x64 version of Windows. I need it to be easily redistributable because my professor demands that he should be able to compile or run our programs without a hitch or he won't grade it. If someone could help out a desperate fool, that would be great. All I need is a link or some quick explanation of the best way to go about this. I would write the file input output myself but then I would have to write all kinds of string manipulation code and searching stuff... and I don't have time for that. I just need a simple to code database which I'm sure exists (Right?).
Advertisement
I used the mysql connector with java and found it quite simple, You just install a redist of easyPhp which will setup everything for you on the database side. Just create a database and a table with phpmyadmin (done in 10 clicks or so)
On the java side, I dont remember how to load the driver class but it was fairly simple.
My 2 cents (barely)
Hrm, that seemed a little complicated for my time available, but thanks for the pennies. I found this little tutorial by searching some of your advice which hopefully will turn out to work easily.

http://www.cs.wcupa.edu/~rkline/mysql-java-win.html
Hmm, you said "saving and loading information"... did you acually mean setting up a database and everything? Cause if not, then there's no reason why you can't hack up a quick flatfile manipulator with just the basic java libraries.
Could you please elaborate janta, because I've been up for nearly 26 hours and will be up for another 9 in order to finish this and hand it in (I know its better to sleep, but this the only deciding factor: fail or pass). I think I've been terribly barking up the wrong tree with mysql with my tired decisions and low production... I haven't gotten far with it, so would you care to point me in the right direction?

Oh and I guess I haven't explained what I'm trying to do. I've made most of a Stratego clone. The file operations are needed for the AI. I'm saving some basic information about the pieces that the computer opponent uses in order to make decisions. The game will load up the info, use it, and change it as necassary. So it only needs local access.
Use a text file to store the data with simple file manipulator methods to retrieve and update them, then hardcode everything though it won't look pretty it should work well enough.
The only java file operations I've used (or know of) are the FileOutputStream/FileInputStream classes in java.io. I know they're probably the most basic ones but they are a little annoying to setup. I don't have any of my past classes that used those as my USB drive went through the wash today (with this project completed. how convenient, eh?). I'll use them if anyone knows of an existing class that uses them in a way similar to what I need.

I know I'm making nothing but requests but I hope you guys can understand the anxiety this has put on me. I had this project done weeks ago but now I have to work off a month old hard drive save of it.
Hey
As you asked for a database system, I pointed at one that is very simple, but still overkilling if you're just to read/write a few bytes on your hard drives. What exactly do you need to do ?

Concerning mysql, I'm sorry but I have uninstalled everything quite a month ago and I wont remember anything special. All I remember is you just have to install easyphp (in which the interesting part is the mysql server and the phpmyadmin tool) Then using phpmyadmin you create a new database, and in this database you create whatever table you'd need for your app. From there your system is ready for read/write (as user=root and no password)

In your java program, just do exactly what is explained in the tutorial you mentioned, that is, load the driver with Class.forName(), then create a connection using classes from java.sql package. From there you should be ready to issue whatever query to your database (SELECT to read, UPDATE to write)

Considering your situation (especially the deadline ^^) maybe you'dbetter stick with usual file read/write if you're more confident with that. However, using a database can provide you with a very easy way to read/write structured information (saves you the pain of parsing a text file for exemple) I've been in emergency situation like this before (who has not...) so basically what everyone would recommend (I think) is whatever you decide, stick with it and KISS (keep it simple and stupid) for I guess you'll be better with a simple functionnal solution than with a great idea that you didnt have time to implement.

My 0.5 cents ... sorry that I cant really be of more help.
I'll sacrifice a chicken to bring you luck ;-)

Janta.

This topic is closed to new replies.

Advertisement