nus-cs2113-AY2223S1 / forum

4 stars 0 forks source link

Store database online and copy when program is run #38

Open joshuan98 opened 1 year ago

joshuan98 commented 1 year ago

We are using our own database which is stored online. May we confirm that we can use java.net.URL to download said database when the .jar file is run? This allows the user to simply run the .jar file instead of having to download the database with it.

From the following link: https://nus-cs2113-ay2223s1.github.io/website/admin/tp-constraints.html#recommendation-minimal-network it appears that we are able to do so and our backup would be for the user to download the database when he/she downloads the .jar file.

joshuan98 commented 1 year ago

Yup, we are not using any DBMS (no SQL is used), its a pure .csv file

chydarren commented 1 year ago

PS yes I realized it's not a DBMS / SQL

okkhoy commented 1 year ago

May we confirm that we can use java.net.URL to download said database when the .jar file is run?

Yes, you can use java.net.URL. However, if for whatever reason the CSV file doesn't get downloaded, resulting in your app being unusable, you risk losing marks because of lack of testability.

You can consider packaging the CSV as a resource within the JAR for a more independent solution.

ongzhihong commented 1 year ago

Remember to create a resources directory in your main and add it in your project structure so that the resources folder is included when you build your jar file.

Also when you want to get the file from resource in your code, you can use either getResource() or getResourceAsStream() and becareful about the file paths!

You can read up at this link: https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getResource(java.lang.String)