Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » Hibernate: driver not found com.mysql.JDBC.driver
Hibernate: driver not found com.mysql.JDBC.driver [message #111877] |
Thu, 07 February 2008 14:27 |
Yigal Spinner Messages: 127 Registered: July 2009 |
Senior Member |
|
|
I created a simple Plugin that uses Teneo, Hibernate and mySql.
When I run my unit test directly on the class that does the database
persistence operations, all tests pass.
When I run my test as a plugin then I get an error that the Hibernate
can not find the mySql driver. The Unit test uses Junit3 and in
headless mode.
I have the mySQL plugin from the Eclipse web site as a dependency.
I have the mySQL JAR in a lib directory and set the classpath to point
to it. I tried all kind of combination, but I can not make it work.
Here is the code for setting the hibernate:
final Properties teneoProperties = new Properties();
teneoProperties.setProperty(PersistenceOptions.USE_MAPPING_F ILE, "true");
final Properties hibernateProperties = new Properties ();
hibernateProperties.setProperty(Environment.DRIVER,
"com.mysql.jdbc.Driver");
hibernateProperties.setProperty(Environment.USER, "root");
hibernateProperties.setProperty(Environment.PASS, "dba");
hibernateProperties.setProperty(Environment.URL,
"jdbc:mysql://picardv3.accenture.com:3306/yigaldb");
hibernateProperties.setProperty(Environment.DIALECT,
org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
// Initialize dataStore
String datastoreName = "domain";
dataStore = HbHelper.INSTANCE.createRegisterDataStore(datastoreName);
dataStore.setEPackages(new EPackage[] { DomainPackage.eINSTANCE });
dataStore.setPersistenceProperties(teneoProperties);
dataStore.setHibernateProperties(hibernateProperties);
dataStore.initialize();
Any ideas how to fix this?
Thanks
Yigal
|
|
|
Re: Hibernate: driver not found com.mysql.JDBC.driver [message #111878 is a reply to message #111877] |
Thu, 07 February 2008 14:34 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Yigal,
Which classpath property did you point to the mysql jar?
For a plugin project this should be specified in the META-INF/Manifest.MF. So for a plugin project
you should not use the classpath project properties directly. For a plugin project the classpath
from the manifest.mf is added to the project properties so it works for both a normal junit run and
for a plugin run.
btw, I don't think that you need to use the mysql plugin for just running teneo/hibernate/mysql
(maybe you have other reasons), the jar file would be enough.
gr. Martin
Yigal wrote:
> I created a simple Plugin that uses Teneo, Hibernate and mySql.
> When I run my unit test directly on the class that does the database
> persistence operations, all tests pass.
>
> When I run my test as a plugin then I get an error that the Hibernate
> can not find the mySql driver. The Unit test uses Junit3 and in
> headless mode.
>
> I have the mySQL plugin from the Eclipse web site as a dependency.
> I have the mySQL JAR in a lib directory and set the classpath to point
> to it. I tried all kind of combination, but I can not make it work.
>
> Here is the code for setting the hibernate:
>
> final Properties teneoProperties = new Properties();
>
> teneoProperties.setProperty(PersistenceOptions.USE_MAPPING_F ILE, "true");
> final Properties hibernateProperties = new Properties ();
> hibernateProperties.setProperty(Environment.DRIVER,
> "com.mysql.jdbc.Driver");
> hibernateProperties.setProperty(Environment.USER, "root");
> hibernateProperties.setProperty(Environment.PASS, "dba");
> hibernateProperties.setProperty(Environment.URL,
> "jdbc:mysql://picardv3.accenture.com:3306/yigaldb");
> hibernateProperties.setProperty(Environment.DIALECT,
> org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
>
> // Initialize dataStore
> String datastoreName = "domain";
> dataStore = HbHelper.INSTANCE.createRegisterDataStore(datastoreName);
> dataStore.setEPackages(new EPackage[] {
> DomainPackage.eINSTANCE });
> dataStore.setPersistenceProperties(teneoProperties);
> dataStore.setHibernateProperties(hibernateProperties);
> dataStore.initialize();
>
>
> Any ideas how to fix this?
>
> Thanks
> Yigal
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Hibernate: driver not found com.mysql.JDBC.driver [message #615428 is a reply to message #111877] |
Thu, 07 February 2008 14:34 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Yigal,
Which classpath property did you point to the mysql jar?
For a plugin project this should be specified in the META-INF/Manifest.MF. So for a plugin project
you should not use the classpath project properties directly. For a plugin project the classpath
from the manifest.mf is added to the project properties so it works for both a normal junit run and
for a plugin run.
btw, I don't think that you need to use the mysql plugin for just running teneo/hibernate/mysql
(maybe you have other reasons), the jar file would be enough.
gr. Martin
Yigal wrote:
> I created a simple Plugin that uses Teneo, Hibernate and mySql.
> When I run my unit test directly on the class that does the database
> persistence operations, all tests pass.
>
> When I run my test as a plugin then I get an error that the Hibernate
> can not find the mySql driver. The Unit test uses Junit3 and in
> headless mode.
>
> I have the mySQL plugin from the Eclipse web site as a dependency.
> I have the mySQL JAR in a lib directory and set the classpath to point
> to it. I tried all kind of combination, but I can not make it work.
>
> Here is the code for setting the hibernate:
>
> final Properties teneoProperties = new Properties();
>
> teneoProperties.setProperty(PersistenceOptions.USE_MAPPING_F ILE, "true");
> final Properties hibernateProperties = new Properties ();
> hibernateProperties.setProperty(Environment.DRIVER,
> "com.mysql.jdbc.Driver");
> hibernateProperties.setProperty(Environment.USER, "root");
> hibernateProperties.setProperty(Environment.PASS, "dba");
> hibernateProperties.setProperty(Environment.URL,
> "jdbc:mysql://picardv3.accenture.com:3306/yigaldb");
> hibernateProperties.setProperty(Environment.DIALECT,
> org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
>
> // Initialize dataStore
> String datastoreName = "domain";
> dataStore = HbHelper.INSTANCE.createRegisterDataStore(datastoreName);
> dataStore.setEPackages(new EPackage[] {
> DomainPackage.eINSTANCE });
> dataStore.setPersistenceProperties(teneoProperties);
> dataStore.setHibernateProperties(hibernateProperties);
> dataStore.initialize();
>
>
> Any ideas how to fix this?
>
> Thanks
> Yigal
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Goto Forum:
Current Time: Fri Sep 20 08:14:05 GMT 2024
Powered by FUDForum. Page generated in 0.05367 seconds
|