-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: No Primary Key?
PostPosted: Tue Jun 07, 2005 11:44 am 
Beginner
Beginner

Joined: Thu Mar 31, 2005 5:59 pm
Posts: 34
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 11:57 am 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
According to the stack trace C3P0 can't find your JDBC driver. Are you sure this is set in the classpath?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 12:09 pm 
Beginner
Beginner

Joined: Thu Mar 31, 2005 5:59 pm
Posts: 34
Yes, I'm sure the driver is in there because it was working perfectly fine before I added the new class. That's why I was so confused by the error.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 12:22 pm 
Beginner
Beginner

Joined: Thu Mar 31, 2005 5:59 pm
Posts: 34
Hmm, on a second deeper look, it does appear that I am having bigger problems than I was initially seeing. Thanks for your help - hopefully I can get these driver issues worked out and get it working again - anyone know how to talk the magic fairies into giving back my drivers they stole?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 12:24 pm 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
Some sort of sacrifice should do the trick. I find irritating cow-orkers work best.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 12:26 pm 
Beginner
Beginner

Joined: Thu Mar 31, 2005 5:59 pm
Posts: 34
Haha, got it! Thanks for your help. I feel dumb for not ensuring my drivers were really there first! (I swore they were there, really!!)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.