Some relevant info to the other info below:
-I have the mySQL server running when I run my junit test.
-I have a database already set up in mySQL called "registration". When I type "show databases;" I get back an entry "registration".
Thanks in advance for any help!
Hibernate version:
3.0
Mapping documents:
hibernate.cfg.xml
Code:
<!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="RegistrationFactory">
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/registration</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="hbm2ddl.auto">update</property>
<property name="hibernate.cglib.use_reflection_optimizer">false</property>
<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">11</property>
<property name="c3p0.timeout">1800</property>
<property name="c3p0.max_statements">10</property>
</session-factory>
</hibernate-configuration>
Code between sessionFactory.openSession() and session.close():Below is the JUnit test I ran that caused the exception listed further belowCode:
package com.nyesg.business.hibernate.tests;
import com.nyesg.registration.dao.HibernateRegistrationDAO;
import junit.framework.TestCase;
public class TestHibReg extends TestCase {
public void test1 () {
HibernateRegistrationDAO hrd = new HibernateRegistrationDAO();
}
}
[/i]
Full stack trace of any exception that occurs:
org.hibernate.HibernateException: Could not find datasource
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:48)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:349)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:58)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1509)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
at com.nyesg.registration.dao.HibernateRegistrationDAO.setup(HibernateRegistrationDAO.java:18)
at com.nyesg.registration.dao.GenericDAO.<init>(GenericDAO.java:6)
at com.nyesg.registration.dao.HibernateRegistrationDAO.<init>(HibernateRegistrationDAO.java:9)
at com.nyesg.business.hibernate.tests.TestHibReg.test1(TestHibReg.java:9)
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 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
... 22 more
Name and version of the database you are using:
mySQL 4.1.9
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: