Connecting to a Database

Hi,

I am new to Vaadin and I just tried to get access to a hsql database.
But it doesn’t work… :frowning:
… and I would be very happy if someone could help me!

The type of Exception I get is:
java.lang.ClassNotFoundException: org.hsqldb.jdbc.JDBCDriver

In my init() method I included the example shown in the Book of Vaadin:


try {
JDBCConnectionPool pool = new SimpleJDBCConnectionPool(
“org.hsqldb.jdbc.JDBCDriver”, “jdbc:hsqldb:mem:.”, “SA”, “”);
System.out.println(pool.toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

I imported as follows:

import org.hsqldb.*;
import org.hsqldb.jdbc.JDBCDriver;

The classpath contains a reference to the jar:

… and I ran the runManagerSwing.bat script in the hsqldb bin folder to generate a database.

Is there anything I have forgotten?
Please let me know! I am quite helpless at the moment :frowning:

Kind regards,
Laura

Hi,

Your Server (Tomcat?) needs the JDBCDriver too!

Just copy the file hsqldb.jar into the WebContent/WEB-INF/lib folder of your project. Refresh the directory (in eclipse) and maybee you must compile the widgetset of your project.

Hope this helps!

Norbert

Hi Norbert,

thank you very much for your reply! :slight_smile:
I could solve the problem by adding the jar in the run configuration classpath field of my project. Before I added it via the build path.
Actually I don’t really understand the difference, but at least it works! :slight_smile:

Have a nice sunday!

Lara