【问题标题】:Connecting JDBC with Firebirdsql使用 Firebirdsql 连接 JDBC
【发布时间】:2017-06-18 08:47:58
【问题描述】:

我在连接 firebirdsql 时遇到问题。 这是我的代码。

 try {

        Class.forName("org.firebirdsql.jdbc.FBDriver");
        Connection con= DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:C:\\EMPLOYEE.FDB","sysdba","masterkey");
        Statement stm= con.createStatement();
        ResultSet res= stm.executeQuery("SELECT * FROM Emp");
        while (res.next()) {
            System.out.println("EMPLOYEE NAME:"
                    + res.getString("NAME"));
        }
    } catch (Exception e) {
        System.out.println(e);
    } 

得到一个类似的错误。

java.lang.ClassNotFoundException: org.firebirdsql.jdbc.FBDriver

【问题讨论】:

标签: java jdbc firebird jaybird


【解决方案1】:

java.lang.ClassNotFoundException: org.firebirdsql.jdbc.FBDriver 表示您的类路径中没有 Jaybird(Firebird JDBC 驱动程序),因为 Java 无法加载驱动程序类。

您可以从https://www.firebirdsql.org/en/jdbc-driver/下载Jaybird

当您运行应用程序时,您需要确保jaybird-full-2.2.12.jar(或jaybird-2.2.12.jarlib/connector-api-1.5.jar)位于类路径中。

这意味着您要么需要将其包含在清单中,要么需要在运行 Java 时显式指定:

java -cp .;jaybird-full-2.2.12.jar MyClass

或者,如果您使用 Maven,则可以使用以下方式包含依赖项:

<dependency>
    <groupId>org.firebirdsql.jdbc</groupId>
    <artifactId>jaybird-jdk18</artifactId>
    <version>2.2.12</version>
</dependency>

另请参阅Jaybird JDBC Driver Java Programmer's Manual,特别是第 2 章。

Jaybird 2.2 及更高版本不需要使用Class.forName("org.firebirdsql.jdbc.FBDriver");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-14
    • 2015-09-24
    • 2018-01-09
    • 2013-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    相关资源
    最近更新 更多