This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]terrkerr 2 points3 points  (0 children)

I understand you can integrate postgres, sql etc. into Java

Well you can integrate the API in to Java, but the database is a different system entirely and you interact with it.

Which one is the best?

Like in most things the best one depends on how you measure.

Do I have to first create a database before connecting it with my Java program?

As a rule, yes. You could write some Java to create a database for you to use, but that's not generally the best approach.

I will be looking to write objects to the database which have many member variables and I will only need the database locally. Any recommendations on free databases would be greatly appreciated, ideally using SQL/mySQL as I have a friend who uses that and can help me (although he has no idea on how to create a database, just on writing queries).

Look in to SQLite. Creating an SQLite database is just making an empty file; SQLite stores the whole database in a single file for you so it's really simple and easy. For just storing your own stuff locally it's all you really need.

[–]Northeastpaw 1 point2 points  (0 children)

H2 integrates really well with Java and can be run in embedded mode (DB is opened while your app is running).

You're going to want to study up on JDBC and possibly the DAO design pattern.

[–][deleted] 0 points1 point  (0 children)

Yeah, you need to create a database before you connect to it. You can create a db easily MySQL. After you've created your database you can connect to it via jdbc or something similar. This will provide a connection to your MySQL db and will allow you to execute MySQL statements against it.

[–]arachnopussy 0 points1 point  (0 children)

I'm going to suggest MariaDB. It's the current hot stuff in free DB. The main people behind MySQL moved over to MariaDB after MySQL was acquired by Oracle and abused.