Foros del Web » Programación para mayores de 30 ;) » Java »

hibernate con firebird

Estas en el tema de hibernate con firebird en el foro de Java en Foros del Web. Hola! Estoy intentando realizar una aplicación con el netbeans, utilizando struts e hibernate y me sale un error en el momento de conectar la base ...
  #1 (permalink)  
Antiguo 20/03/2007, 12:36
 
Fecha de Ingreso: marzo-2007
Mensajes: 7
Antigüedad: 17 años, 9 meses
Puntos: 0
hibernate con firebird

Hola! Estoy intentando realizar una aplicación con el netbeans, utilizando struts e hibernate y me sale un error en el momento de conectar la base de datos.
Mi clase HibernateUtil es la siguiente:

public class HibernateUtil {
private static SessionFactory sessionFactory = null;
static {
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
ex.printStackTrace();
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static Session getSession (){
return HibernateUtil.getSessionFactory().getCurrentSessio n();
}
}

y mi hibernate.cfg.xml es:

<property name="hibernate.connection.driver_class">org.fireb irdsql.jdbc.FBDriver </property>
<property name="hibernate.connection.url"> jdbc:firebirdsql:localhost:INTRANETIFOUR</property>
<property name="hibernate.dialect"> org.hibernate.dialect.FirebirdDialect </property>
<property name="hibernate.connection.password">#k@ssike!</property>
<property name="hibernate.connection.username">CACIQUE</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.No CacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

así pues, he colocado el archivo "jaybird-full-2.0.1" para que interprete el dialecto de FireBird en mi carpeta "lib".
He colocado el archivo "INTRANETIFOUR.FDB" que corresponde a la base de datos en "C:\INTRANETIFOUR.FDB", y he añadido la línia
"INTRANETIFOUR = c:\INTRANETIFOUR.fdb" en el documento "aliases" dentro del directorio de "Firebird". Esos son todos los pasos que he realizado, desconozco si estan correctamente y supongo que deben ser similares a los realizados con otro dialecto. Si alguién puede ayudarme...

El error que me sale es el siguiente:

javax.servlet.ServletException: Cannot open connection
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:1194)
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)
org.netbeans.modules.web.monitor.server.MonitorFil ter.doFilter(MonitorFilter.java:362)


causa raíz

org.hibernate.exception.GenericJDBCException: Cannot open connection
org.hibernate.exception.SQLStateConverter.handledN onSpecificException(SQLStateConverter.java:103)
org.hibernate.exception.SQLStateConverter.convert( SQLStateConverter.java:91)
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:420)
org.hibernate.jdbc.ConnectionManager.getConnection (ConnectionManager.java:144)
org.hibernate.jdbc.JDBCContext.connection(JDBCCont ext.java:129)
org.hibernate.transaction.JDBCTransaction.begin(JD BCTransaction.java:57)
org.hibernate.impl.SessionImpl.beginTransaction(Se ssionImpl.java:1290)
sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.hibernate.context.ThreadLocalSessionContext$Tr ansactionProtectionWrapper.invoke(ThreadLocalSessi onContext.java:301)
$Proxy0.beginTransaction(Unknown Source)
com.myapp.struts.Persistencia.FuncionarioDAO.recup eraFuncionari(FuncionarioDAO.java:45)
com.myapp.struts.ValidateEmployeeAction.execute(Va lidateEmployeeAction.java:31)
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:1194)
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)
org.netbeans.modules.web.monitor.server.MonitorFil ter.doFilter(MonitorFilter.java:362)

gracias!
  #2 (permalink)  
Antiguo 21/03/2007, 05:53
 
Fecha de Ingreso: marzo-2007
Mensajes: 7
Antigüedad: 17 años, 9 meses
Puntos: 0
Re: hibernate con firebird

hola de nuevo! descubri algo mas sobre mi error:

12:44:32,156 INFO TilesRequestProcessor:103 - Tiles definition factory found for request processor ''.
12:44:32,203 INFO Environment:479 - Hibernate 3.1.3
12:44:32,203 INFO Environment:509 - hibernate.properties not found
12:44:32,203 INFO Environment:525 - using CGLIB reflection optimizer
12:44:32,218 INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
12:44:32,296 INFO Configuration:1308 - configuring from resource: /hibernate.cfg.xml
12:44:32,296 INFO Configuration:1285 - Configuration resource: /hibernate.cfg.xml
12:44:32,468 INFO Configuration:1419 - Configured SessionFactory: null
12:44:32,484 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
12:44:32,484 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
12:44:32,484 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
12:44:32,515 INFO DriverManagerConnectionProvider:80 - using driver: org.firebirdsql.jdbc.FBDriver at URL: jdbc:firebirdsql:localhost:8084:INTRANETIFOUR
12:44:32,515 INFO DriverManagerConnectionProvider:86 - connection properties: {user=CACIQUE, password=****}
12:44:33,031 WARN SettingsFactory:103 - Could not obtain connection metadata
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544375. unavailable database
Reason: unavailable database
at org.firebirdsql.jdbc.FBDataSource.getConnection(FB DataSource.java:122)
at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.jav a:131)
at java.sql.DriverManager.getConnection(DriverManager .java:525)
at java.sql.DriverManager.getConnection(DriverManager .java:140)
at org.hibernate.connection.DriverManagerConnectionPr ovider.getConnection(DriverManagerConnectionProvid er.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(Se ttingsFactory.java:72)
at org.hibernate.cfg.Configuration.buildSettings(Conf iguration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1174)
at com.myapp.struts.hibernate.HibernateUtil.<clinit>( HibernateUtil.java:75)
at com.myapp.struts.Persistencia.FuncionarioDAO.recup eraFuncionari(FuncionarioDAO.java:44)
at com.myapp.struts.ValidateEmployeeAction.execute(Va lidateEmployeeAction.java:31)
at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFil ter.doFilter(MonitorFilter.java:362)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
at
org.firebirdsql.gds.GDSException: unavailable database
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl. readStatusVector(AbstractJavaGDSImpl.java:2124)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl. receiveResponse(AbstractJavaGDSImpl.java:2074)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl. internalAttachDatabase(AbstractJavaGDSImpl.java:41 4)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl. iscAttachDatabase(AbstractJavaGDSImpl.java:370)
at org.firebirdsql.jca.FBManagedConnection.<init>(FBM anagedConnection.java:89)
at org.firebirdsql.jca.FBManagedConnectionFactory.cre ateManagedConnection(FBManagedConnectionFactory.ja va:470)
at org.firebirdsql.jca.FBStandAloneConnectionManager. allocateConnection(FBStandAloneConnectionManager.j ava:69)
at org.firebirdsql.jdbc.FBDataSource.getConnection(FB DataSource.java:119)
at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.jav a:131)
at java.sql.DriverManager.getConnection(DriverManager .java:525)
at java.sql.DriverManager.getConnection(DriverManager .java:140)
at org.hibernate.connection.DriverManagerConnectionPr ovider.getConnection(DriverManagerConnectionProvid er.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(Se ttingsFactory.java:72)
at org.hibernate.cfg.Configuration.buildSettings(Conf iguration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1174)
at com.myapp.struts.hibernate.HibernateUtil.<clinit>( HibernateUtil.java:75)
at com.myapp.struts.Persistencia.FuncionarioDAO.recup eraFuncionari(FuncionarioDAO.java:44)
at com.myapp.struts.ValidateEmployeeAction.execute(Va lidateEmployeeAction.java:31)
at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFil ter.doFilter(MonitorFilter.java:362)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
12:44:33,171 INFO Dialect:103 - Using dialect: org.hibernate.dialect.FirebirdDialect
12:44:33,250 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
12:44:33,265 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
12:44:33,265 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
12:44:33,265 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
12:44:33,359 INFO SettingsFactory:144 - Scrollable result sets: disabled
12:44:33,359 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
12:44:33,359 INFO SettingsFactory:160 - Connection release mode: auto
12:44:33,359 INFO SettingsFactory:187 - Default batch fetch size: 1
12:44:33,359 INFO SettingsFactory:191 - Generate SQL with comments: disabled
12:44:33,359 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
12:44:33,359 INFO SettingsFactory:338 - Query translator:
[...]

Unavailable database... alguna ayuda???
Gracias
  #3 (permalink)  
Antiguo 21/03/2007, 06:39
 
Fecha de Ingreso: octubre-2003
Mensajes: 3.578
Antigüedad: 21 años, 2 meses
Puntos: 51
Re: hibernate con firebird

No he usado nunca Firebird, pero... ¿estas seguro que la cadena de conexion "jdbc:firebirdsql:localhost:INTRANETIFOUR" es correcta?

¿Y en caso de que lo sea, esta el servidor de BDD puesto en marcha en el puerto que le especificas? ¿Puedes conectarte abriendo una conexion normal?....
  #4 (permalink)  
Antiguo 22/03/2007, 04:45
 
Fecha de Ingreso: marzo-2007
Mensajes: 7
Antigüedad: 17 años, 9 meses
Puntos: 0
Re: hibernate con firebird

Al fin!!!! Creo que lo conseguí!
Tal y como decías mi url estaba mal, tiene que ser:

jdbc:firebirdsql://localhost/INTRANETIFOUR

Así parece ser que funciona! aun no funciona nada, pero como minimo ya establece conexión con la base de datos porque me da errores en los mapeamientos...Lo que me ha costado descubrir el problema! porque estaba trabajando sobre una base de datos sobre la cual no podía acceder (dice que problema de contraseña y login...pero esto aun no he descubierto porque pasa). Lo cierto es que he cambiado la base de datos a la que acceder y me da errores al mapear, o sea que diria que voy bien.

Gracias!!!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:20.