Failed to connect hypersonic(HSQLDB) DB on Apache 7.0

寵の児 提交于 2019-12-11 10:54:18

问题


I have a project in Eclipse which is defined as 'Dynamic web project' on Apache-Tomcat 7.0 server.
I need to connect to hypersonic DB (HSQLDB) in some of my Java classses.

The code which i'm trying to make is very simple:

private Connection getConnection(){
    Connection conn;

    try {   
        Class.forName("org.hsqldb.jdbcDriver");
        conn = driverManager.getConnection("jdbc:hsqldb:hsql://localhost","sa","");
        return conn;
    } 
    catch (Exception e) {
        e.printStackTrace();
    }   
    return null;
}

I already added hsqldb.jar to some lib library which located in my project and defined in the Java build path over Eclipse.

The problem is that I'm getting this error:

java.lang.ClassNotFoundException: org.hsqldb.jdbcDriver
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1722)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1573)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at root.login.getConnection(login.java:75)
    at root.login.doPost(login.java:35)

So it cannot find the org.hsqldb.jdbcDriver class for some reason.
I have to say that I made this configuration many times before that, and it all went well.

Funny story:
I managed to have another simple Java project with main function and this function over the same configuration, and it went well on the exact same machine.

  • What can I do in order to find this class?
  • Is there any more information that I need to tell you to make it clearer?

回答1:


In a web application, you have to add the hsqldb.jar file into WEB-INF/lib folder of the application (or into $TOMCAT_HOME/lib folder, if you have more webapps using it). To have it just in Eclipse project's classpath is not enough.



来源:https://stackoverflow.com/questions/32101108/failed-to-connect-hypersonichsqldb-db-on-apache-7-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!