Hola, tengo una aplicaciòn que usa struts e hibernate. Al correrla me tira el siguiente error:
org.hibernate.exception.GenericJDBCException: Cannot open connection
Estos son algunos contenidos:
"hibernate.cfg.xml"
<?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="connection.driver_class">com.mysql.jdbc.Driv er</property>
<property name="connection.url">jdbc:mysql://localhost/personas</property>
<property name="connection.username">admin</property>
<property name="connection.password"></property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="transaction.factory_class">org.hibernate.tra nsaction.JDBCTransactionFactory</property>
<!-- Mapping files -->
<mapping resource="vista/PersonaBO.hbm.xml"/>
</session-factory>
</hibernate-configuration>
-------------
La pila de errores completa es:
javax.servlet.ServletException
org.apache.struts.action.RequestProcessor.processE xception(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
causa raíz
exceptions.DatastoreException
exceptions.DatastoreException.datastoreError(Datas toreException.java:28)
SearchPersonAction3.execute(SearchPersonAction3.ja va:67)
org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
causa raíz
exceptions.DatastoreException
exceptions.DatastoreException.datastoreError(Datas toreException.java:28)
PersonsManager2.getPersona(PersonsManager2.java:40 )
SearchPersonAction3.execute(SearchPersonAction3.ja va:38)
org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
causa raíz
org.hibernate.exception.GenericJDBCException: Cannot open connection
org.hibernate.exception.SQLStateConverter.handledN onSpecificException(SQLStateConverter.java:91)
org.hibernate.exception.SQLStateConverter.convert( SQLStateConverter.java:79)
org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionHelper.java:43)
org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionHelper.java:29)
org.hibernate.jdbc.ConnectionManager.openConnectio n(ConnectionManager.java:327)
org.hibernate.jdbc.ConnectionManager.getConnection (ConnectionManager.java:118)
org.hibernate.jdbc.AbstractBatcher.prepareQuerySta tement(AbstractBatcher.java:105)
org.hibernate.loader.Loader.prepareQueryStatement( Loader.java:1561)
org.hibernate.loader.Loader.doQuery(Loader.java:66 1)
org.hibernate.loader.Loader.doQueryAndInitializeNo nLazyCollections(Loader.java:224)
org.hibernate.loader.Loader.loadEntity(Loader.java :1785)
org.hibernate.loader.entity.AbstractEntityLoader.l oad(AbstractEntityLoader.java:93)
org.hibernate.loader.entity.AbstractEntityLoader.l oad(AbstractEntityLoader.java:81)
org.hibernate.persister.entity.AbstractEntityPersi ster.load(AbstractEntityPersister.java:2730)
org.hibernate.event.def.DefaultLoadEventListener.l oadFromDatasource(DefaultLoadEventListener.java:36 5)
org.hibernate.event.def.DefaultLoadEventListener.d oLoad(DefaultLoadEventListener.java:346)
org.hibernate.event.def.DefaultLoadEventListener.l oad(DefaultLoadEventListener.java:123)
org.hibernate.event.def.DefaultLoadEventListener.p roxyOrLoad(DefaultLoadEventListener.java:177)
org.hibernate.event.def.DefaultLoadEventListener.o nLoad(DefaultLoadEventListener.java:87)
org.hibernate.impl.SessionImpl.fireLoad(SessionImp l.java:889)
org.hibernate.impl.SessionImpl.get(SessionImpl.jav a:826)
org.hibernate.impl.SessionImpl.get(SessionImpl.jav a:819)
PersonsManager2.getPersona(PersonsManager2.java:33 )
SearchPersonAction3.execute(SearchPersonAction3.ja va:38)
org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
----------------------------------
Por otro lado tengo:
"PersonsManager2.java"
public class PersonsManager2 implements IManejadorPersonas
{
SessionFactory sessionFactory = null;
public PersonsManager2()throws DatastoreException
{
init();
}
public PersonaBO getPersona(String id1)throws DatastoreException
{
PersonaBO personaBO = null;
Session session = null;
try
{
session = sessionFactory.openSession();
personaBO = (PersonaBO)session.get(PersonaBO.class,id1);
session.close();
}catch (Exception ex)
{
ex.printStackTrace();
throw DatastoreException.datastoreError(ex);
}
return personaBO;
}
private void init()throws DatastoreException
{
try
{
sessionFactory=new Configuration().configure().buildSessionFactory();
}catch(Exception ex){
throw DatastoreException.datastoreError(ex);
}
}
}
Bueno, no sè còmo atacar este problema
Gracias y saludos