0

There is a local application that I use for testing purposes. It is running on an tomcat server that is executed via IntelliJ IDEA. Now I want to build an API that I can send a HTTP-Request to (something like http://%myAddress%:8123/rate) and then a new database entry is created. For the database I would like to use h2 database engine.

I have done some research on how to use h2 and found this post.

Now I tried to import that module. Since this is a maven application, I added a new dependency:

<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <version>1.4.196</version>
</dependency>

And then I created a new class where I want to initialize the Database structure:

package mypackage;

import org.h2.jdbcx.JdbcDataSource;

public class DataBaseInitializer {

    public DataBaseInitializer() {

    }

}

Sadly the import is failing, since he Cannot resolve symbol 'h2'.

What did I do wrong?

Rüdiger
  • 893
  • 5
  • 27
  • 56
  • Did you verify the H2 jar hit downloaded and is now present within your IntelliJ project? If it is not, you may not have set Maven to "auto-import", that is, react to your addition of another dependency in the POM file. You will need to trigger Maven now to do its thing (download the jar). – Basil Bourque Oct 22 '17 at 16:51

1 Answers1

0

org.h2.jdbcx.JdbcDataServer doesn't seem like a correct class. Check H2 database documentation. The org.h2.jdbcx.JdbcDataSource class is used for creating the data source.

Andrey
  • 15,144
  • 25
  • 91
  • 187