-1

Am developing application in springboot using Msaccess database. My database file placed inside src/main/resources. I have configured database details in application.properties file. When I tried to load database file in application.properties its not working. Below is what I have tried in application.properties file.

spring.datasource.url=jdbc:ucanaccess://classpath:database.accdb

When I run the application, it return error message:

UCAExc:::4.0.4 given file does not exist: classpath:database.accdb

FakeAlcohol
  • 860
  • 7
  • 28
Jai
  • 352
  • 2
  • 18

2 Answers2

2

The driver cannot understand that classpath: is a special prefix. It expects a filename (real file path in a filesystem) and classpath:database.accdb is not a real one. Consider constructing the URL dynamically in Java code using ResourceUtils.getFile (this method will return real file name for a classpath resource). Note that it will throw a FileNotFoundException if the resource cannot be resolved to a file in the file system as it may be the case (e.g. when the resource is inside a JAR file).

madhead
  • 31,729
  • 16
  • 153
  • 201
  • So, Is there any way to assign file in application.properties which is in classpath.? – Jai Aug 13 '19 at 10:41
1

Below post is going to help you

Accessing a Microsoft Access database that is saved in the classpath

As i commented earlier, it should be an absolute path or path to the source directoy.

Prasad
  • 1,089
  • 13
  • 21