0

i have read

and searched the web for: "cannot resolve symbol jdbc" with zero results.

I changed pom.xml but gives Error Dependency 'org.xerial:hsqldb-jdbc:' not found:

    <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <version>2.3.2</version>
        <scope>test</scope>
    </dependency>

    <!-- bellow is not working (red in IDE): -->
    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>hsqldb-jdbc</artifactId>
        <version></version>
        <scope>test</scope>
    </dependency>

And tried much much more.

What else i could do and try?

So far I had only programmed in finished Spring applications. This should be my first Spring application that I write from the beginning (defaults: Jetty, hsqldb).

SL5net
  • 2,282
  • 4
  • 28
  • 44

1 Answers1

1

I'm not really sure where you got this hsqldb-jdbc dependency but it seems that it is no longer in org.xerial group. You can see it in MVN Repository that there is no such dependency.

As far as I understand, you need this dependency to succesfully connect to the HSQLDB. To connect to database, do following:

  1. Add HSQLDB without test scope as follows:
<dependency>
    <groupId>org.hsqldb</groupId>
    <artifactId>hsqldb</artifactId>
    <version>2.4.0</version>
</dependency>
  1. Create application.properties in your resources folder

For on-disk database:

spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver 
spring.datasource.url=jdbc:hsqldb:hsql://localhost/testdb 
spring.datasource.username=sa 
spring.datasource.password= 
spring.jpa.hibernate.ddl-auto=update

For in-memory database:

spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:mem:testdb;DB_CLOSE_DELAY=-1
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=create
  1. Create entities
  2. Create Repositories
  3. Test it all out

Take a look at this Spring Boot HSQLDB integration tutorial for more

Alexander Gusev
  • 295
  • 1
  • 9
  • i get "Cannot resolve class 'JDBCDriver'" seems connected with maybe this: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360001677580-JDBC-driver-class-not-resolved-in-Spring-Boot-application-yml-during-code-analysis , https://www.programmersought.com/article/87461736589/ – SL5net Mar 12 '21 at 11:30
  • 1
    I updated my answer with point #1. You are trying to add HSQLDB with scope "test" which means that it will be enabled only for tests. What you actually need is to have this dependency for all scopes – Alexander Gusev Mar 12 '21 at 11:42
  • 1
    You have it in your pom with test. Remove this scope and refresh dependencies. Then you won't have "Cannot resolve class 'JDBCDriver'" error in application.properties – Alexander Gusev Mar 12 '21 at 11:53
  • implemented but error still there: https://i.imgur.com/VlaypyI.png – SL5net Mar 12 '21 at 11:58
  • 1
    Well that's another error with your implementation of `UserDaoImpl`. I would suggest you go through this tutorial and adjust code accordingly: https://www.baeldung.com/spring-boot-hsqldb – Alexander Gusev Mar 12 '21 at 12:04
  • this tutorial using version 2.4.0 that produce errors. in my pom i use 2.3.2 that seems give not early errors: https://i.imgur.com/YK17nFA.png – SL5net Mar 12 '21 at 13:45
  • I looked at the baeldung.com page and it has a small but significant error. The Server start command should be like this: java -cp ../lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:testdb --dbname0.testdb – fredt Mar 12 '21 at 14:26