Hibernate version: 3.1
Name and version of the database you are using: MySQL Server 5.0
Hi from newbie ;)
I'm occuring a problem with the Configuration class i think at the configure() method. Simply i just can't build the SessionFactory. What i know is that the program tries to connect to the DB cause my firewall detects a connection on the localhost. Here's the code.
Code:
package pkg;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class GoDB
{
public static void main(String[] args)
{
Session session = null;
try
{ Configuration cfg = new Configuration();
cfg.configure();
SessionFactory sessionFactory = cfg.buildSessionFactory();
session = sessionFactory.openSession();
org.hibernate.Transaction tx = session.beginTransaction();
Message msg = new Message();
msg.setId(4);
msg.setText("some txt");
session.save(msg);
System.out.println("done");
tx.commit();
session.flush();
session.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
finally
{
// session.flush();
// session.close();
}
}
}
This is my hibernate.cfg.xml file.
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"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:3306/message</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">xxx</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="pkg/message.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Message that i get from eclipse
Full stack trace of any exception that occurs:
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.hibernate.cfg.SettingsFactory.createCacheProvider(SettingsFactory.java:327)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:219)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at pkg.GoDB.main(GoDB.java:16)
I would be grateful for any help.