无法在Apache 7.0上连接高超音速(HSQLDB)数据库 [英] Failed to connect hypersonic(HSQLDB) DB on Apache 7.0

查看:155
本文介绍了无法在Apache 7.0上连接高超音速(HSQLDB)数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中有一个项目,在Apache-Tomcat 7.0服务器上定义为动态web项目。

我需要连接到 hypersonic 我的一些Java类中的DB(HSQLDB)。

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;
}

我已添加 hsqldb.jar 到一些 lib 库,它位于我的项目中,并在Eclipse上的 Java构建路径中定义。

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

问题是我收到此错误:

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)

所以它出于某种原因无法找到 org.hsqldb.jdbcDriver 类。

我必须说我之前已多次进行此配置,并且一切顺利。

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.


有趣的故事:
我设法在同一个配置上创建了另一个带有main函数和这个函数的简单Java项目,并且
它在同一台机器上运行良好。

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.




  • 我该怎么做才能找到这个班级?

  • 有没有我需要告诉您更多信息以使其更清晰?

  • 推荐答案

    在Web应用程序中,你必须将 hsqldb.jar 文件添加到应用程序的 WEB-INF / lib 文件夹中(或者进入 $ TOMCAT_HOME / lib 文件夹,如果你有更多使用它的webapps)。仅仅在Eclipse项目的类路径中使用它是不够的。

    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.

    这篇关于无法在Apache 7.0上连接高超音速(HSQLDB)数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆