Hibernate version: 3.0
Mapping documents: <hibernate-mapping schema="SUPPORT">
<class name="com.expd.app.gci.util.exchange.CDBSupportBatchControlExchangeObject" table="BATCH_CONTROL"> <id name="branch" column="BRANCH"/>
<property name="branchCode" column="BRANCH_CODE" type="string"/> </class>
</hibernate-mapping>
Full stack trace of any exception that occurs: org.hibernate.HibernateException: JDBC Driver class not found: COM.ibm.db2.jdbc.app.DB2Driver at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:70) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80) at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:301) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:111) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1505) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1053) at com.expd.app.gci.util.HibernateCDBUtils.getSession(HibernateCDBUtils.java:29) at com.expd.app.gci.api.HibernateCdbApi.delegateQuery(HibernateCdbApi.java:71) at com.expd.app.gci.api.HibernateCdbApiTest.testDelegateQuery(HibernateCdbApiTest.java:92) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:436) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:311) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: java.lang.ClassNotFoundException: COM.ibm.db2.jdbc.app.DB2Driver at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108) at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:65) ... 23 more
Name and version of the database you are using: DB2 2.2.49
Here is the problem I'm having. I'm using a legacy DB that is not my own - it is someone else's within my company. I cannot change this DB, but I need to read from it. For whatever reason, when setting up the tables, they did not put a primary key of any kind on one of their tables.
At first, not thinking I tried to run with the following mapping file:
<class name="com.expd.app.gci.util.exchange.CDBSupportBatchControlExchangeObject"
table="BATCH_CONTROL">
<property name="branch"
column="BRANCH"
type="string"/>
<property name="branchCode"
column="BRANCH_CODE"
type="string"/>
</class>
</hibernate-mapping>
As expected, I got an error that I cannot have a table without a primary key. Looking at the data, it appears that the BRANCH column is always unique, so I decided to make it the primary key. When I did, I got the above exception.
What I'm wondering is - could the above exception have been caused because the table has no primary key or does it indicate some flaw in my programming logic?
In case this helps, this is where I create the session:
Configuration cfg = new Configuration();
cfg.addClass(CDBShipLogClientExchangeObject.class);
cfg.addClass(CDBSupportBatchControlExchangeObject.class);
SessionFactory sessions = cfg.buildSessionFactory();
Session session = sessions.openSession();
The error occurs on the last line. Before I added this table/class, it ran fine (with just CDBShipLogClientExchangeObject.class).
Thanks!
Susan Alexander
|