2

I'm trying to use a DB for reading and writing that is contained in a JAR. I can read in it, but can't write throwed exeception :

java.sql.SQLException: path to '/database/scddata.db': 'LocationOfJar/database' does not exist

Is there any way I can bundle the database file inside a JAR?

Thanks in advance.

1
  • Will you read only on this db or write also? Commented May 15, 2016 at 21:56

1 Answer 1

4

Jar files does not allows to write.

So :

  1. define a working path (in properties for example). Let's call it : workingPath/file.db.

  2. on init of your program, before opening your db.

    • check if db exists in working path
    • if does not exists : copy your jar file.db file to workingPath/file.db .
  3. Then you program will use the db from workingPath/file.db for execution.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.