r/javahelp • u/[deleted] • Aug 23 '19
Distributing java app that utilizes JDBC
Hi, all
So I've created a application for my fantasy football league that utilizes a database that I've created on my local machine. In my java source code I query the database using JDBC. I know that a jar file is used to distribute java apps to other people, but I am confused as to how to distribute the database portion of the app.
1
Aug 23 '19
Realistically doesnt matter if it's the same DB or local to their machines. If it's local I would need to distribute it weekly to update the values in the non temp tables. Thank you for the example
3
u/johnmc325 Aug 23 '19
You didn't say if all the distributed apps should use a single database or if they should each use their own version. Makes a difference to the answer.
If everyone needs to use the same database then as others have said you need to provide a database accessible from the web like in the cloud.
If each needs their own then look at embedded databases, where you app creates and uses the database for each instance. If this is what you want then take a look at my worked example of this to give you an idea of what to do. http://softwarepulse.co.uk/tutorials/java-with-sqlite-embedded-database/
1
Aug 23 '19
You can get a free amazon EC2 instance for year when you sign up to AWS. You could use that to host your database. You'll need to keep an eye on the size though, or you'll charged. It's not very expensive though. If it's just for a few of your mates to play together it shouldn't be a problem.
1
u/aenigmaclamo Extreme Brewer Aug 23 '19
Either distribute a database dump or data files which your application can use to insert data into your database.
Consider also using a tool like flyway which allows you to do database migrations that keep your db changes version controlled
9
u/Coins_Bounce Aug 23 '19
You can look into H2 and each user will only have access to their respective data. Otherwise, host a database somewhere and point each application to it.