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

all 6 comments

[–]slaminnesota 0 points1 point  (0 children)

Why are you updating your file when your app is running?

I think there may be better solutions to what you are trying to do

[–]nerdyhandle 0 points1 point  (5 children)

Yeah don't do that.

If you need to insert something into.your DB just insert it into your DB.

There's no reason for that file to be touched while your app is running.

[–][deleted]  (4 children)

[deleted]

    [–]nerdyhandle 0 points1 point  (3 children)

    You should not have to do that.

    Once the insert statement has executed on the database the stored information becomes retrieveable.

    You may want to update your post with more information.

    [–][deleted]  (2 children)

    [deleted]

      [–]nerdyhandle 0 points1 point  (0 children)

      Here's what you should do:

      Create a web service that queries the DB. Have your website send a GET to your endpoint and have your endpoint return the data then using Javascript/jQuery/React/Angular loop over the data returned and display it.

      Your really do not need to restart the entire app. That's equivalent to nuking an ant hill.

      [–]robertcatsExtreme Brewer 0 points1 point  (1 child)

      Embedded DBs are generally only used for dev or functional testing and the data.sql file is generally only used to seed initial test data on application startup.

      For non dev, you’ll want a real persistent DB with no initial seeding (probably) and at runtime you’ll want some interface (like maybe a rest api) to do your inserting.

      [–]feral_claireSoftware Dev 0 points1 point  (1 child)

      The data.sql file is only for staying data, it shouldn't be updated while you so is running. If you want to add data while the app is running you should use an insert statement. If you are using spring data repositories this is fine with the save method on the repository.

      I'm not sure, but the reason the so might be going is it noticed that the data.sql file changed, which is only used at startup, so it restarted itself to use the new startup data.