-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

Leo
  • 634
  • 5
  • 24
Jai
  • 340
  • 1
  • 16

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
  • 28,732
  • 15
  • 145
  • 186
  • 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,039
  • 12
  • 20