I'm developing with eclipse 3.1 and hibernate.
I had the following error with the configuration file for DB2:
14:46:36,247 WARN SettingsFactory:95 - Could not obtain connection metadata
java.sql.SQLException: No suitable driver
I've added the db2 library db2jcc.jar and db2jcc_license_cu.jar to the classpath.
I successfully tried the same code with other configuration file for Oracle and SAP DB.
Can anyone help me ?
Thanks in advance,
Paolo.
Configuration file:
################################### ### Apache DBCP Connection Pool ### ###################################
## connection pool
hibernate.dbcp.maxActive 2 hibernate.dbcp.whenExhaustedAction 1 hibernate.dbcp.maxWait 120000 hibernate.dbcp.maxIdle 10
## prepared statement cache
#hibernate.dbcp.ps.maxActive 5 #hibernate.dbcp.ps.whenExhaustedAction 1 #hibernate.dbcp.ps.maxWait 120000 #hibernate.dbcp.ps.maxIdle 10
## optional query to validate pooled connections:
hibernate.dbcp.validationQuery select 1 from dual hibernate.dbcp.testOnBorrow true hibernate.dbcp.testOnReturn false
################################# ### Plugin ConnectionProvider ### #################################
hibernate.connection.provider_class net.sf.hibernate.connection.DBCPConnectionProvider
Hibernate version: 2.1
Mapping documents: <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<!-- una istanza di SessionFactory indicata con il suo /nome/jndi --> <session-factory>
<!-- proprietà --> <property name="show_sql">true</property> <property name="dialect">net.sf.hibernate.dialect.DB2Dialect</property> <property name="connection.url">jdbc:db2//localhost:50000/DSGR</property> <property name="connection.driver_class">com.ibm.db2.jcc.DB2Driver</property> <property name="connection.username">Administrator</property> <property name="connection.password">gasperina</property>
<!-- mapping files --> <mapping resource="dsgr/dao/db2/dstutente.hbm.xml"/> <mapping resource="dsgr/dao/db2/dssoggetto.hbm.xml"/> <mapping resource="dsgr/dao/db2/dsrapporto.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
12:46:00,623 INFO Environment:462 - Hibernate 2.1.4 12:46:00,633 INFO Environment:496 - loaded properties from resource hibernate.properties: {hibernate.dbcp.whenExhaustedAction=1, hibernate.cglib.use_reflection_optimizer=true, hibernate.dbcp.maxIdle=10, hibernate.dbcp.maxWait=120000, hibernate.dbcp.maxActive=2, hibernate.dbcp.validationQuery=select 1 from dual, hibernate.dbcp.testOnBorrow=true, hibernate.connection.provider_class=net.sf.hibernate.connection.DBCPConnectionProvider, hibernate.dbcp.testOnReturn=false} 12:46:00,633 INFO Environment:522 - using CGLIB reflection optimizer 12:46:00,643 INFO Configuration:872 - configuring from resource: /db2.cfg.xml 12:46:00,643 INFO Configuration:844 - Configuration resource: /db2.cfg.xml 12:46:00,723 INFO Configuration:328 - Mapping resource: dsgr/dao/db2/dstutente.hbm.xml 12:46:00,803 INFO Binder:229 - Mapping class: dsgr.dao.DSTUtente -> TUSERS 12:46:00,843 INFO Configuration:328 - Mapping resource: dsgr/dao/db2/dssoggetto.hbm.xml 12:46:00,873 INFO Binder:229 - Mapping class: dsgr.dao.DSSoggetto -> TSOGG 12:46:00,873 INFO Configuration:328 - Mapping resource: dsgr/dao/db2/dsrapporto.hbm.xml 12:46:00,893 INFO Binder:229 - Mapping class: dsgr.dao.DSRapporto -> TRAPP 12:46:00,943 INFO Binder:169 - Mapping subclass: dsgr.dao.DSCliente -> TRAPP 12:46:00,943 INFO Binder:169 - Mapping subclass: dsgr.dao.DSControparte -> TRAPP 12:46:00,953 INFO Binder:169 - Mapping subclass: dsgr.dao.DSDepositaria -> TRAPP 12:46:00,953 INFO Configuration:1030 - Configured SessionFactory: null 12:46:00,953 INFO Configuration:613 - processing one-to-many association mappings 12:46:00,953 INFO Configuration:622 - processing one-to-one association property references 12:46:00,953 INFO Configuration:647 - processing foreign key constraints 12:46:00,963 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.DB2Dialect 12:46:00,973 INFO SettingsFactory:62 - Use outer join fetching: true 12:46:00,973 INFO ConnectionProviderFactory:53 - Initializing connection provider: net.sf.hibernate.connection.DBCPConnectionProvider 12:46:00,973 INFO DBCPConnectionProvider:56 - DBCP using driver: com.ibm.db2.jcc.DB2Driver at URL: jdbc:db2//localhost:50000/DSGR 12:46:00,983 INFO DBCPConnectionProvider:57 - Connection properties: {user=Administrator, password=gasperina} 12:46:01,023 INFO DBCPConnectionProvider:89 - DBCP prepared statement pooling disabled 12:46:01,033 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended) 12:46:01,033 WARN SettingsFactory:95 - Could not obtain connection metadata java.sql.SQLException: No suitable driver at java.sql.DriverManager.getConnection(DriverManager.java:532) at java.sql.DriverManager.getConnection(DriverManager.java:140) at org.apache.commons.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:97) at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:300) at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:816) at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:140) at net.sf.hibernate.connection.DBCPConnectionProvider.getConnection(DBCPConnectionProvider.java:41) at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72) at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1132) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:766) at dsgr.DSRuntime.init(DSRuntime.java:56) at dsgr.privatebanking.PBWorkbenchAdvisor.preStartup(PBWorkbenchAdvisor.java:30) at org.eclipse.ui.internal.Workbench.init(Workbench.java:817) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1325) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:254) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at dsgr.privatebanking.ApplicationPB.run(ApplicationPB.java:28) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:335) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:704) at org.eclipse.core.launcher.Main.main(Main.java:688) 12:46:01,033 INFO SettingsFactory:102 - Use scrollable result sets: false 12:46:01,033 INFO SettingsFactory:105 - Use JDBC3 getGeneratedKeys(): false 12:46:01,033 INFO SettingsFactory:108 - Optimize cache for minimal puts: false 12:46:01,043 INFO SettingsFactory:114 - echoing all SQL to stdout 12:46:01,043 INFO SettingsFactory:117 - Query language substitutions: {} 12:46:01,043 INFO SettingsFactory:128 - cache provider: net.sf.ehcache.hibernate.Provider 12:46:01,043 INFO Configuration:1093 - instantiating and configuring caches 12:46:01,163 INFO SessionFactoryImpl:119 - building session factory 12:46:01,534 INFO SessionFactoryObjectFactory:82 - no JNDI name configured 12:46:02,355 WARN JDBCExceptionReporter:38 - SQL Error: 0, SQLState: 08001 12:46:02,355 ERROR JDBCExceptionReporter:46 - No suitable driver 12:46:02,365 ERROR JDBCExceptionReporter:38 - Cannot open connection
Name and version of the database you are using: DB2 ver. 8.1
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|