-->
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.  [ 5 posts ] 
Author Message
 Post subject: SQLException : No suitable driver
PostPosted: Sun Mar 19, 2006 6:19 pm 
Newbie

Joined: Sun Mar 19, 2006 6:09 pm
Posts: 2
Location: Glasgow
Hibernate version:
3.1

Mapping documents:
net.eudaimonia.model :

<?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="net.eudaimonia.model">

<class name="CustomerDetails" table="CUSTOMER_DETAILS" lazy="true">
<comment>Customer details hibernate object to database mapping configuration...</comment>

<id name="id" column="ID" type="integer">
<generator class="select" />
</id>

<property name="title" type="string">
<column name="TITLE" sql-type="varchar(8)" not-null="true" />
</property>
<property name="forename" type="string">
<column name="FORENAME" sql-type="varchar(35)" not-null="false" />
</property>
<property name="surname" type="string">
<column name="SURNAME" sql-type="varchar(35)" not-null="true" />
</property>
<property name="address1" type="string">
<column name="ADDRESS1" sql-type="varchar(100)" not-null="true" />
</property>
<property name="address2" type="string">
<column name="ADDRESS2" sql-type="varchar(100)" not-null="false" />
</property>
<property name="address3" type="string">
<column name="ADDRESS3" sql-type="varchar(100)" not-null="false" />
</property>
<property name="address4" type="string">
<column name="ADDRESS4" sql-type="varchar(100)" not-null="false" />
</property>
<property name="postcode" type="string">
<column name="POSTCODE" sql-type="varchar(9)" not-null="true" />
</property>
<property name="workPhone" type="string">
<column name="WORK_PHONE" sql-type="varchar(20)" not-null="false" />
</property>
<property name="homePhone" type="string">
<column name="HOME_PHONE" sql-type="varchar(20)" not-null="false" />
</property>
<property name="mobilePhone" type="string">
<column name="MOBILE_PHONE" sql-type="varchar(20)" not-null="false" />
</property>
<property name="email" type="string">
<column name="EMAIL" sql-type="varchar(50)" not-null="true" />
</property>
<property name="termsAgreed" type="string">
<column name="TERMS_AGREED" sql-type="varchar(1)" not-null="true" />
</property>
<property name="contact" type="string">
<column name="CONTACT" sql-type="varchar(1)" not-null="false" />
</property>
</class>

</hibernate-mapping>

Full stack trace of any exception that occurs:
Buildfile: C:\Development\eclipse\workspaces\Eudaimonia-v1.0\eudaimonia-java\resources\eudaimonia-templates\hibernateOperations.xml
init:
schemaExport:
[schemaexport] (cfg.Environment 479 ) Hibernate 3.1.2
[schemaexport] (cfg.Environment 509 ) hibernate.properties not found
[schemaexport] (cfg.Environment 525 ) using CGLIB reflection optimizer
[schemaexport] (cfg.Environment 555 ) using JDK 1.4 java.sql.Timestamp handling
[schemaexport] (cfg.Configuration 240 ) Reading mappings from file: C:\Development\eclipse\workspaces\Eudaimonia-v1.0\eudaimonia-java\source\net\eudaimonia\model\CustomerDetails.hbm.xml
[schemaexport] (cfg.HbmBinder 309 ) Mapping class: net.eudaimonia.model.CustomerDetails -> CUSTOMER_DETAILS
[schemaexport] (dialect.Dialect 103 ) Using dialect: org.hibernate.dialect.MySQL5Dialect
[schemaexport] (hbm2ddl.SchemaExport 155 ) Running hbm2ddl schema export
[schemaexport] (hbm2ddl.SchemaExport 177 ) writing generated schema to file: C:\Development\eclipse\workspaces\Eudaimonia-v1.0\eudaimonia-java\resources\hibernate-content\schema-export.sql
[schemaexport] (hbm2ddl.SchemaExport 182 ) exporting generated schema to database
[schemaexport] (connection.DriverManagerConnectionProvider 41 ) Using Hibernate built-in connection pool (not for production use!)
[schemaexport] (connection.DriverManagerConnectionProvider 42 ) Hibernate connection pool size: 0
[schemaexport] (connection.DriverManagerConnectionProvider 45 ) autocommit mode: false
[schemaexport] (connection.DriverManagerConnectionProvider 80 ) using driver: java.sql.Driver at URL: java:comp/env/jdbc/dev
[schemaexport] (connection.DriverManagerConnectionProvider 86 ) connection properties: {user=developer, password=****}
[schemaexport] (hbm2ddl.SchemaExport 208 ) schema export unsuccessful
[schemaexport] java.sql.SQLException: No suitable driver
[schemaexport] at java.sql.DriverManager.getConnection(DriverManager.java:545)
[schemaexport] at java.sql.DriverManager.getConnection(DriverManager.java:140)
[schemaexport] at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
[schemaexport] at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:467)
[schemaexport] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:183)
[schemaexport] at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:146)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:341)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[schemaexport] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[schemaexport] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[schemaexport] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[schemaexport] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[schemaexport] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
BUILD SUCCESSFUL
Total time: 7 seconds


Name and version of the database you are using:
MySQL 5.1

I'm running an ANT 1.6.5 script to perform the SchemaExportTask however I can't get past the issue above. I reckon this is due to the MySQL driver com.mysql.jdbc.Driver not being found.

My full Ant script is pasted below:

<project name="HibernateOperations" default="schemaExport" basedir=".">
<property name="project.name" value="eudaimonia-java" />

<property name="source.dir" value="${basedir}/../../source" />
<property name="output.dir" value="${basedir}/../hibernate-content" />
<property name="output.file" value="${output.dir}/schema-export.sql" />

<property name="hibernate.properties" value="${output.dir}/hibernate.properties" />

<property name="classpath.base" value="C:/Development/APIS" />

<path id="hibernate.classpath">
<path>
<pathelement location="${classpath.base}/hibernate/hibernate3.jar" />
<pathelement location="${classpath.base}/mysql-connector-java-3.0.17-ga/mysql-connector-java-3.0.17-ga-bin.jar" />
<fileset dir="${classpath.base}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${classpath.base}/mysql-connector-java-3.0.17-ga/lib">
<include name="**/*.jar" />
</fileset>
</path>
</path>

<!-- Create the build directory -->
<target name="init">
<mkdir dir="${output.dir}" />
</target>

<target name="schemaExport" depends="init">
<taskdef name="schemaexport" classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="hibernate.classpath" />

<schemaexport properties="${hibernate.properties}" quiet="no" text="no"
drop="no" delimiter=";" output="${output.file}">
<fileset dir="${source.dir}">
<include name="**/*.hbm.xml" />
</fileset>
</schemaexport>
</target>

<target name="schemaUpdator" depends="init">
<taskdef name="schemaupdate"
classname="org.hibernate.tool.hbm2ddl.SchemaUpdateTask"
classpathref="hibernate.classpath" />

<schemaupdate properties="${hibernate.properties}" quiet="no">
<fileset dir="${source.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaupdate>
</target>

<target name="schemaValidator" depends="init">
<taskdef name="schemavalidator"
classname="org.hibernate.tool.hbm2ddl.SchemaValidatorTask"
classpathref="hibernate.classpath" />

<schemavalidator
properties="${hibernate.properties}">
<fileset dir="${source.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemavalidator>
</target>
</project>

hibernate.properties:
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=java:comp/env/jdbc/dev
hibernate.connection.username=<REMOVED>
hibernate.connection.password=<REMOVED>

I'm running in the eclipse 3.1.2 IDE and have tried putting the MySQL JAR file in every conceivable location but still it can't find it. I have the same issue with log4j but in order to fix this more prevalent issue I removed the log4j.jar from my hibernate directory so the commons logger would be used instead.

I've read some posts with this or similar however they did not fix my issue, i've been at this for over a week and its got me! If anyone can help me with this that would rock :)

Regards





Caley


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 20, 2006 2:56 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
in your hibernate.properties make sure you have defined it with the MYSQL driver similar to this:

hibernate.dialect org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql:///db1
hibernate.connection.username bob
hibernate.connection.password secret

and make sure the hibernate.properties is in your classpath, as well as the jar file to the mysql driver.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 20, 2006 2:58 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
the format for the mysql URL is:

jdbc:mysql://servername/databasename

and if you don't specify servername it defaults to localhost (the current machine).

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 7:17 pm 
Newbie

Joined: Sun Mar 19, 2006 6:09 pm
Posts: 2
Location: Glasgow
Thanks mate :)

Case of not seeing the wood for the trees lol

Was using my JNDI lookup instead of the URL.

All is working ok now :)

Do you know what happened to the 'format' attribute? In the Hi9bernate manual it is there but I get an error when setting it? Has it been removed, if so was there a replacement for it?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 1:18 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
no problem - glad it helped; and thanks for rating 'y' on the posts. I appreciate it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.