i have a war with classes that use hibernate. this component has been build and tested under zindows without error (tomcat + mysql on localhost)
second stage i try to put this war on a linux machine (tomcat 5 + mysql 4.0.22) and i already have the same pb of jdbc connection:
at the beginning i believed that the pb came from the policy in tomcat but i have delete all policy and start tomcat without the option -policy.
i have test my db user with mysql ... no pb.
i use chainsow to trace log and hibernate say me the it found the right info
about the db (driver and jdbc url seems to be fine)
my url is: connection.url=jdbc:mysql://localhost:3306/bd
driver:connection.driver_class=com.mysql.jdbc.Driver
i have turn log4j level to TRACE and no more errors appears.
this error qppeqrs qt the beginning in the class:
net.sf.hibernate.cfg.SettingsFactory when it try to get metadata from db>
i use a debian system without a deb package of tomcat5 (from
http://apt.leapster.org/tomcat).
I don't use jndi ressource to get a jdbc connection, is it important ?
any help is welcome
Thx
Christophe
Hibernate version:2.1.4
Mapping documents:<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>
<!-- Settings for a remote MySQL database. -->
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<!-- <property name="connection.driver_class">org.gjt.mm.mysql.Driver</property> -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://127.0.0.1:3306/bd</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<!-- Use the C3P0 connection pool. -->
<!-- <property name="c3p0.min_size">5</property> -->
<!-- <property name="c3p0.max_size">20</property> -->
<!-- <property name="c3p0.timeout">1800</property> -->
<!-- <property name="c3p0.max_statements">50</property> -->
<!-- Use EHCache but not the query cache. -->
<!-- <property name="cache.provider_class">net.sf.ehcache.hibernate.Provider</property> -->
<!-- <property name="cache.use_query_cache">false</property> -->
<!-- <property name="cache.use_minimal_puts">false</property> -->
<!-- properties -->
<!-- Print SQL to stdout. -->
<property name="show_sql">true</property>
<!-- mapping files -->
<mapping resource="org/jteam/bd/hibernate/Album.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Realisation.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Auteur.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Collection.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Editeur.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Edition.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Pays.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Serie.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1690)
at com.mysql.jdbc.Connection.<init>(Connection.java:427)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:395)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:101)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3302)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3282)
at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2227)
at org.jteam.bd.util.HibernateUtil.find(HibernateUtil.java:282)
at org.jteam.bd.util.HibernateUtil.find(HibernateUtil.java:228)
at org.jteam.bd.MainPage.initTextTitle(MainPage.java:60)
at org.jteam.bd.MainPage.<init>(MainPage.java:38)
at org.jteam.bd.MyBdInstance.initContent(MyBdInstance.java:120)
at org.jteam.bd.MyBdInstance.init(MyBdInstance.java:91)
at nextapp.echo.EchoInstance.doInit(EchoInstance.java:186)
at nextapp.echoservlet.InstancePeer.init(InstancePeer.java:792)
at nextapp.echoservlet.Initializer.service(Initializer.java:229)
at nextapp.echoservlet.Connection.process(Connection.java:459)
at nextapp.echoservlet.EchoServer.process(EchoServer.java:314)
at nextapp.echoservlet.EchoServer.doPost(EchoServer.java:234)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Name and version of the database you are using:mysql 4.0.22
The generated SQL (show_sql=true):not yet because the error is on the connection
Debug level Hibernate log excerpt:TRACE