-->
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: problems with my first app (Hibernate + MySQL)
PostPosted: Wed Nov 08, 2006 1:08 pm 
Newbie

Joined: Tue Nov 07, 2006 7:13 am
Posts: 9
Location: Barcelona
Hi I'm Blai and I'm a newbie in Hibernate.
First, my apologies for I might be doing silly questions here. I'm a bit confused
and trying to build my first application with Hibernate 3 and MySQL. So this is my story:

To test Hibernate I have 3 tables in MySQL (Person, Email, Telephone) with their relations
defined. Very simple database for all I want is get to know how Hibernate works.
Then with eclipse I have developed 3 classes, one for each table, in java. These
classes just contain the attributes and the getter and setter methods.
The next step I took was to attach to my application the libraries for hibernate and jdbc.
Once I had this I went for for the Hibernate configuration:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="testingHibernate">
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.password">XXXXXXXXXX</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="hibernate.connection.username">YYYYYYYYYY</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
</session-factory>
</hibernate-configuration>

And also I tried to provide myself with a console configuration.
Then from the java classes I've built the mappings for the 3 classes.These look like:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="modulPersonal">
<class name="CorreuElectronic" table="correuelectronic">
<id name="identifier" column="identifier" />
<property name="email" column="email" />
<many-to-one name="persona" class="dadespersonals">
<column name="dadespersonals" />
</many-to-one>
</class>
</hibernate-mapping>

Then I followed in testing all features of Hibernate in eclipse and opend the window
view for the Hibernate configurations where you can see my "HiberTest" console configuration.
If you click on that you'll get the following message:

Error while fetching children. Reason:
org.hibernate.console.HibernateConsoleRuntimeException
Problems while loading database drivers
org.gjt.mm.mysql.Driver
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver


So the question is obvious here: What am I doing wrong?
As I said above, I'm a bit confused and I don't know what comes frist java or the
mappings? I need some advice on this and somebody tell me how to fix this problem
with the MySQL driver.
The idea would be, as a start, to build an application that performs 4 basic sql
instructions: insert, select, update and delete.

Thank you very much in advance for your help.
Any idea would be appreciated.
Regards,
Blai

_________________
Veles e vents han mos desig complir faent camins dubtosos per la mar.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 08, 2006 1:18 pm 
Newbie

Joined: Thu Nov 10, 2005 6:05 am
Posts: 16
is the jar that contains org.gjt.mm.mysql.Driver on the classpath?
(is this a plugin project? eclipse sometimes does strange things during plugin loading.)

ivan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 09, 2006 4:07 am 
Newbie

Joined: Tue Nov 07, 2006 7:13 am
Posts: 9
Location: Barcelona
hi,

thanks Ivan for your reply.
I can't see any jar or whatever named "org.gjt.mm.mysql.Driver" or so, but I do can import this library to my java classes.
I mean I'm able to put in my java file the following:

import org.gjt.mm.mysql.Driver;


So I don't really know where this error comes from!! Doing an import of library means it is on your path for your project, doesn't it?

Many thanks to everyone,

Blai

_________________
Veles e vents han mos desig complir faent camins dubtosos per la mar.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 15, 2006 11:19 am 
Newbie

Joined: Thu Nov 10, 2005 6:05 am
Posts: 16
Quote:
Doing an import of library means it is on your path for your project, doesn't it?


not necesseraly. for example if you develop an eclipse plugin or an eclipse rcp application, you should explicitly put it on the classpath in the plugin manifest.

if your application is nat an rcp app, then maybe HibernateTools has its own classpath... unfortunately, I don't use HibernateTools, so I can't help with it.

what if you try it without HibernateTools?

ivan[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 15, 2006 2:39 pm 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
Download the mysql-java connector jar from http://dev.mysql.com/downloads/connector/j/5.0.html and put the jar file in your classpath. The application is not able to find the jdbc driver for connecting to mysql.


Top
 Profile  
 
 Post subject: fixed it!! (hibernate console configuration tool bug?)
PostPosted: Thu Nov 16, 2006 7:51 am 
Newbie

Joined: Tue Nov 07, 2006 7:13 am
Posts: 9
Location: Barcelona
Hi you there,

I have fixed the issue about my driver for MySQL. The whole thing goes as follows:

I am using eclipse to develop my first application with hibernate. I have the plugins for the hibernate tools but apparently some doesn't work properly. When using these tools for the hibernate console configuration I couldn't get through my application tree to the mysql connector jar. So I thought that just selecting the folder it would do. There the problem came.
By chance, today I could make my way to this jar file and now it is working just fine.

So my advice would be: when editing your hibernate console configuration with the proper hibernate tool make sure when you use "add jar/dir" button that you can browse your driver. Otherwise, if you only reach the folder, write down the full name of the jar file containing the driver yourself. If you don't it won't work.

Many thanks to all that helped me with it.

Regards,

Blai

_________________
Veles e vents han mos desig complir faent camins dubtosos per la mar.


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.