No suitable driver found for jdbc:firebirdsql://localhost:3050

1.2k Views Asked by At

I build a javafx maven app , using jaybird dependency . Every thing work fine from intelliJ. when i export the jar file ,I receive this message :

No suitable driver found for jdbc:firebirdsql://localhost:3050...

enter image description here project structure

this is dependencies part of pom.xml:

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>16</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>16</version>
        </dependency>
        <dependency>
            <groupId>org.firebirdsql.jdbc</groupId>
            <artifactId>jaybird-jdk16</artifactId>
            <version>2.2.14</version>
        </dependency>
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>5.5.0</version>
        </dependency>
    </dependencies> 
2

There are 2 best solutions below

1
On BEST ANSWER

The solution is : right click on jaybird dependency(follow the image), then click Extract into output root then rebuild the artifact jar.

0
On

The normal cause of this error occurring is that either you don't have Jaybird (Firebird JDBC driver) - or one of its required dependencies - on your classpath, or the driver was not registered. Driver registration normally happens automatically, but you can always try to do it explicitly using Class.forName("org.firebirdsql.jdbc.FBDriver"). If this fails, you get a stacktrace that provides further information.

Given you show a Maven pom.xml that includes Jaybird (albeit an older version), the driver is present at compile time. However, depending on how you launch your application, it may not be present on the runtime classpath.

There are several options:

  1. Explicitly specify the driver when loading Java:

    java -cp yourapp.jar;jaybird-4.0.3.java8.jar;connector-api-1.5.jar your.class.Name
    

    Here, both jaybird-4.0.3.java8.jar and connector-api-1.5.jar are required for Jaybird to work.

  2. List the required JARs (jaybird-4.0.3.java8.jar and connector-api-1.5.jar) in the Class-Path entry of the manifest of your JAR:

    Class-Path: jaybird-4.0.3.java8.jar connector-api-1.5.jar
    

    Both jar files need to be in the same directory as your JAR. You can then launch your application as (assuming the Main-Class attribute is also specified):

    java -jar yourapp.jar
    
  3. Create a fat (or uber) JAR, and make sure all of Jaybird's classes and resources - and those of its required dependencies - are included in your JAR.

  4. (web applications) Include the driver (and dependencies) in the libraries/modules of your application server (e.g. the Tomcat lib folder), or make sure the driver is included in the WEB-INF/lib folder of your WAR (the Maven WAR plugin takes care of this). In this last case (driver in WEB-INF/lib), it is necessary to explicitly load the driver using Class.forName("org.firebirdsql.jdbc.FBDriver") to ensure the driver is registered.