No suitable driver found when enabling the necessary drivers using maven-assembly-plugin

Possible duplicate:
java error (No suitable driver found)

I also have very little work with PostgreSQL DB, and it would be very convenient to use it as one jar. So I really tried using maven-assembly-plugin as follows:

<artifactId>maven-assembly-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>pack.name.MainClass</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>

And it works fine, I see all the files that I need are added to the jar file, including the driver files, but when I try to run it, I get:

java.sql.SQLException: No suitable driver found for jdbc:postgresql://<ip>:5432/dbname

I have it:

<dependencies>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency> 
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.1-901-1.jdbc4</version>
        </dependency>

In the dependencies and the URL is exactly the same as I wrote above (except for the censorship address :)). What am I missing?

Thank!

+5
source share
1 answer

Class.forName(...) , , maven-assembly-plugin - , jar s.

JDBC- /META-INF/services/java.sql.Driver, jar, ( Oracle Postgres), maven-assembly-plugin.

maven-shade-plugin maven-assembly-plugin, , .

Class.forName(...), .

+10

All Articles