0

I had a problem in connecting with the firebirdsql. here is my code.

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

Getting an ERROR like.

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

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Raj kumar
  • 21
  • 2
  • 6

1 Answers1

2

The java.lang.ClassNotFoundException: org.firebirdsql.jdbc.FBDriver indicates that you do not have Jaybird (the Firebird JDBC driver) on your class path, as Java failed to load the driver class.

You can download Jaybird from https://www.firebirdsql.org/en/jdbc-driver/

You need to make sure that jaybird-full-2.2.12.jar (or jaybird-2.2.12.jar and lib/connector-api-1.5.jar) are on the class path when you run the application.

This means that you either need to include it in the manifest, or you need to explicitly specify it when running Java:

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

Alternatively, if you use Maven, you can include the dependency using:

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

See also the Jaybird JDBC Driver Java Programmer's Manual, specifically chapter 2.

The use of Class.forName("org.firebirdsql.jdbc.FBDriver"); is not necessary with Jaybird 2.2 and higher.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197