您好我正在开发一个struts + hibernate网站。我遇到了hibernate连接问题。当我在我的本地主机中使用它时,它工作正常。问题是我使用与服务器数据库连接用户名和密码相同的配置文件连接未打开。我已将错误消息写入服务器中的文件,并将错误消息显示为“无法打开连接”。休眠无法打开服务器连接
这里是我的Hibernate配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<?xmsl version="1.0" encoding="UTF-8"?>
<hibernate-configuration>
<session-factory name="session1">
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/dev_mydatabase?autoReconnect=false</property>
<property name="hibernate.connection.username">myusername(not original)</property>
<property name="hibernate.connection.password">mypassword(no original)</property>
<property name="show_sql">true</property>
<property name="hibernate.cglib.use_reflection_optimizer">false</property>
<property name="current_session_context_class">managed</property>
<property name="hibernate.c3p0.max_statements">50</property>
<!-- For seeing hibernate log on the console -->
<property name="show_sql">true</property>
<!-- End-->
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="log4j.logger.org.hibernate.SQL">trace</property>
<!-- <property name="hbm2ddl.auto">update</property>-->
<!-- All my mapping files are here.-->
</session-factory>
</hibernate-configuration>
和吾道文件我写查询作为
SessionFactory sessionFactory =
(SessionFactory) ServletActionContext.getServletContext().getAttribute(HibernateListener.KEY_NAME);
Session Hibernatesession = sessionFactory.openSession();
Hibernatesession.beginTransaction();
doctorList = Hibernatesession.createCriteria("Hibernate query will be here").
我不明白什么是这里的问题发生。任何人都请帮助我。
谢谢。
- 显示stactrace – Bozho 2011-12-23 13:22:03