cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CAP - Java > Sqlite db access in Eclipse IDE

somnath
Active Participant
0 Likes
2,392

Hello,

New to CAP Java Domain, so question may sound bit basic 🙂

I am using eclipse IDE to create simple CAP Java application. While trying to use sqlite db , facing challenge to integrate with the DB and running spring-boot:run

Steps follow:

1. basic scenam.cds / service.cds done and I can run spring-boot:run command and it works

2. now added sqlite3 as a dev depedency and executed cds deploy --to sql command which created sqlite.db file under project root directoy.

3. sqlite3 is already installed in my windows machine also, PATH variable is updated.

So when I am running spring-boot:run command it fails

with below error:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.sap.c
ds.framework.spring.config.runtime.CdsRuntimeInitializer': Unsatisfied dependency expressed through field
'services'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating be
an with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boo
t/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Invocation of init method failed; n
ested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execut
e database script from resource [URL [file:/C:/Users/Somnath/eclipse-workspace/orderDemo/srv/target/classe
s/schema.sql]]; nested exception is java.lang.IllegalArgumentException: 'script' must not be null or empty

Do I need to make certain changes in application.yaml file... or something else I need to take care of?

If you please suggest.

Thanks in advance!

-BR.

View Entire Topic
somnath
Active Participant
0 Likes

Thank you so much marcbecker. Yes it solved my problem, but along with this I had to change a little few things and mentioning here in case this helps to someone.

I finally set the application.yaml file as below:

---
spring:
  config.activate.on-profile: default
  datasource:
    auto-config.enabled: false
    url: "jdbc:sqlite:C://Users//Somnath//eclipse-workspace//orderDemo//sqlite.db"
    jdbc.driver: org.sqlite.JDBC
    initialization-mode: never

As I encountered another problem : "Cannot load driver class: org.sqlite. JDBC"

So I add pom dependency: Link

<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
</dependency>

Thanks again Marc!

Closing this thread as answered.

BR.

marcbecker
Product and Topic Expert
Product and Topic Expert

Great!

The spring.datasource.auto-config.enabled property however does not exist.
There is only a cds.datasource.auto-config.enabled property.

Nevertheless setting that property is not required in your scenario, when explicitly specifying a spring.datasource.url property, as that anyway turns of the auto configuration of datasources from service bindings.

Best regards,
Marc