Java - No cosigo que funcione hibernate.

 
Vista:

No cosigo que funcione hibernate.

Publicado por santi (3 intervenciones) el 14/01/2008 16:53:23
Hola a todos. Llevo un tiempo intentando ejecutar un simple ejemplo utilizando hibernate.3.2 Utilizo netbeans 6.0. Cree un proyecto en el que puse el fichero hibernate.cfg.xml en un paquete por defecto: También tengo incluídas los jar de hibernate y las del driver de mysql.

*****************************

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configurati on-3.0.dtd">

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configurati on-3.0.dtd">
<hibernate-configuration>
<session-factory>

<property name="hibernate.connection.connection.url">jdbc :mysql://localhost/centro</property>
<property name="hibernate.connection.connection.driver_class" ;>com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.dialect">org.hiberna te.dialect.MySQLDialect</property>
<property name="hibernate.connection.connection.username"> anonimo</property>
<property name="hibernate.connection.connection.password">anonimo</property>


<property name="transaction.factory_class">
&nbs p; org.hibernate.transaction.JDBCTransactionFactory
</property>
<!-- thread is the short name for
org.hibernate.context.ThreadLocalSessionContext
and let Hibernate bind the session automatically to the thread
-->
<property name="current_session_context_class">thread< /property>
<!-- this will show us all sql statements -->
<property name="show_sql">true</property>

<!-- mapping files -->
<mapping resource="datos/Categoria.hbm.xml" />


</session-factory>
</hibernate-configuration>

***************************



Dentro de un paquete llamado util, tengo el fichero siguiente :HibernateUtil.java

******************************

package util;
import org.hibernate.*;
import org.hibernate.cfg.*;


/**
*
* @author santi
*/
public class HibernateUtil {

private Configuration configuration;
private SessionFactory sessionFactory;
private Session session = null;

public HibernateUtil (){
configuration = null;
sessionFactory = null;
session = null;
}
public Configuration getConfiguration(){

configuration = new Configuration();

return this.configuration;

}

public SessionFactory getSessionFactory(){
if (sessionFactory == null){
try{
sessionFactory = this.getConfiguration().buildSessionFactory();
}
catch (HibernateException e){
System.out.println("Error en la creacion de sessionFactory"+e);
}
}
return this.sessionFactory;

}

public Session getSession(){
if ((session==null) || (!session.isOpen())){
try{
session = getSessionFactory().openSession();
}
catch (HibernateException e){
System.out.println ("Error enla creación de Session");
}
}
return this.session;
}

}
**************************************



De ntro del paquete datos tengo mis clases .java y sus respectivos fichers de mapeos.



::::::: Cuando lo depuro, siempre me salta la excepción en la clase HibernateUtil.java a la hora de ejecutar la siguiente línea:

****** sessionFactory = this.getConfiguration().buildSessionFactory();

< /p>

Los mensajes de aviso que me salen son los siguientes:



*************** *****************

init:
deps-jar:
compile:
14-ene-2008 10:35:41 org.hibernate.cfg.Environment
INFO: Hibernate 3.2.5
14-ene-2008 10:35:41 org.hibernate.cfg.Environment
INFO: hibernate.properties not found
14-ene-2008 10:35:41 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
14-ene-2008 10:35:41 org.hibernate.cfg.Environment
INFO: using JDK 1.4 java.sql.Timestamp handling
14-ene-2008 10:35:42 org.hibernate.connection.UserSuppliedConnectionProvider configure
ADVERTENCIA: No connection properties specified - the user must supply JDBC connections
BUILD STOPPED (total time: 27 minutes 12 seconds)

********************************
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder