-->
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.  [ 1 post ] 
Author Message
 Post subject: JDBC driver issue
PostPosted: Sun Aug 31, 2008 2:50 pm 
Newbie

Joined: Sun Aug 31, 2008 2:38 pm
Posts: 1
Hibernate version:

Hibernate annotations 3.4
Hibernate Tools 3.2.2 beta1
Hibernate Core 3.3 SP1
MySQL Connector 5.1.6

Name and version of the database you are using:

MySQL 5

I am newbie in Hibernate so this issue may be resolved quickly. I want to use MySQL database in my project. However Hibernate core raises exception
ERROR DriverManagerConnectionProvider:88 - JDBC Driver class not found: com.mysql.jdbc.Driver

What is weird the exception is thrown when I run the application. When I launch exportscheme task it is finished fine. And the MySQL connection jar is in classpath for both tasks. I tried changing database to HSQLDb but Hibernate also gave me an exception: JDBC Driver class not found for HSQLDB.

When I tried to load MySQL driver in my startup class it is loaded within an error. However when the execution reaches the Hibernate driver manager it fails.

Here is my hibernate.cfg.xml file

Code:
<!DOCTYPE hibernate-configuration SYSTEM
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost/project
</property>
<property name="hibernate.connection.username">
root
</property>
<property name="hibernate.connection.password">
</property>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<!-- Use the C3P0 connection pool provider -->
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<!-- Show and print nice SQL on stdout -->
<property name="show_sql">true</property>
<property name="format_sql">true</property>
</session-factory>
</hibernate-configuration>


My hibernate.properties

Code:
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost/project
hibernate.connection.username=root
hibernate.connection.password=
hibernate.dialect=org.hibernate.dialect.MySQLDialect


My ant task

Code:
<project name="TourClub" default="compile" basedir=".">
   <!-- Name of project and version -->
   <property name="proj.name" value="Project" />
   <property name="proj.version" value="1.0" />
   <!-- Global properties for this build -->
   <property name="src.java.dir" value="src" />
   <property name="lib.dir" value="lib" />
   <property name="build.dir" value="bin" />
   <!-- Classpath declaration -->
   <path id="project.classpath">
      <fileset dir="${lib.dir}">
         <include name="**/*.jar" />
         <include name="**/*.zip" />
      </fileset>
   </path>
   <!-- Useful shortcuts -->
   <patternset id="meta.files">
      <include name="**/*.xml" />
      <include name="**/*.properties" />
   </patternset>
   <!-- Clean up -->
   <target name="clean">
      <delete dir="${build.dir}" />
      <mkdir dir="${build.dir}" />
   </target>
   <!-- Compile Java source -->
   <target name="compile" depends="clean">
      <mkdir dir="${build.dir}" />
      <javac srcdir="${src.java.dir}" destdir="${build.dir}" nowarn="on" debug="on">
         <classpath refid="project.classpath" />
      </javac>
   </target>
   <!-- Copy metadata to build classpath -->
   <target name="copymetafiles">
      <copy todir="${build.dir}">
         <fileset dir="${src.java.dir}">
            <patternset refid="meta.files" />
         </fileset>
      </copy>
   </target>
   <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="project.classpath" />
   <target name="schemaexport" depends="compile, copymetafiles" description="Exports a generated schema to DB and file">
      <hibernatetool destdir="${basedir}">
         <classpath path="${build.dir}" />
         <!--configuration configurationfile="${build.dir}/hibernate.cfg.xml" /-->
         <annotationconfiguration configurationfile="${build.dir}/hibernate.cfg.xml"/>
         <hbm2ddl drop="true" create="true" export="true" outputfilename="dump.sql" delimiter=";" format="true" />
      </hibernatetool>
   </target>
   <!-- Run -->
   <target name="run" depends="compile, copymetafiles" description="Build and run">
      <java fork="true" classname="org.project.Main" classpathref="project.classpath">
         <classpath path="${build.dir}"/>
      </java>
   </target>
</project>


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

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.