没有合适的驱动程序hibernate postgresql

时间:2017-05-16 12:05:50

标签: java postgresql hibernate maven

我有一个maven项目的临时应用程序。当我做的时候

mvn package -D maven.test.skip=true

它在transitime / target文件夹中创建了一些jar。 它在打包期间写道,包括postgresql:

[INFO] Including postgresql:postgresql:jar:9.1-901.jdbc4 in the shaded jar.

我的postgresql版本是9.1-19,所以驱动程序版本没问题。我检查了一下。

然后我用配置文件运行其中一个罐子,我想正确的数据库名称和凭据和URL。 我得到了:

WARNING: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@72337297 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt 

exception: 
java.sql.SQLException: No suitable driver
    at java.sql.DriverManager.getDriver(DriverManager.java:315)
    at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:240)
    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
    at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
    at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)

据说这个问题是错误的连接URL或没有驱动程序。 我在postgresql_hibernate.xml中配置了:

   <property name="hibernate.dialect">
      org.hibernate.dialect.PostgreSQLDialect
   </property>
   <property name="hibernate.connection.driver_class">
      org.postgresql.Driver
   </property>

在我看来,maven编译不会添加postgresql驱动程序,但包含maven状态。我是maven的新手,但我不知道如何在项目中检查或强制包括司机。或者也许新手的其他东西在这里,我想念。 当我解压缩我执行的jar时,它包括org / postgresql.Driver.class。

==编辑 jdbc url是:jdbc:postgresql://localhost:5432/dbname

0 个答案:

没有答案