0

I am thinking of using JavaFX for a desktop app that will let users to upload files. I was thinking what is the correct approach for this ? Should I use a mysql database to store the references to the files or just dump the files in a folder?

Coming from a web background this is a bit confusing. Also I could contain a JRE in the deployed app so it can run on any machine right (even though that machine does not have a jre)?

Thanks

Trt Trt
  • 5,330
  • 13
  • 53
  • 86
  • 1
    Yes, you can creat a [self-contained package](https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html) for your app and jre. Asking one question per question is preferred. The database question is too broad for StackOverflow. MySQL is not the way to go for your case - that would require somebody to install MySQL to use your app. Maybe use an embedded DB like H2 or just JSON files with no DBMS. Write the app without a DBMS first and add in a DBMS if you need it. – jewelsea Jun 29 '15 at 20:16
  • Thanks that is a good idea. Do you suggest saving the JSON objects in a file (I mean the JSON objects will act as my database records rights?)? – Trt Trt Jun 30 '15 at 15:08
  • Try it Trt Trt. I don't know enough about your application to answer definitively. You may be able to get all the information you need by querying the file system APIs, or you may also need some auxiliary data such as some JSON files to hold metadata not available from the file system directly. – jewelsea Jul 01 '15 at 16:57

1 Answers1

1

If you want everything to be self-contained, you could try an embedded database like ObjectDB. Here's a link to their 4-step tutorial.

What you can do is read in the file as a bytestream, store it in an entity with any other file parameters you'd like (the tutorial explains this), and store that entitiy in the database. ObjectDB will create a small database file for you that can be stored with your app.

Community
  • 1
  • 1
corpico
  • 617
  • 3
  • 16
  • 26