67,512
社区成员
发帖
与我相关
我的任务
分享
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateSession {
private static SessionFactory sf;
static {
Configuration conf=new Configuration().configure();
sf=conf.buildSessionFactory();
}
public static Session openSession() {
return sf.openSession();
}
public static Session getCurrentSession() {
return sf.getCurrentSession();
}
}
ognl.MethodFailedException: Method "login" failed for object com.mine.action.LoginAction@67dd7cf6 [java.lang.ExceptionInInitializerError]
Caused by: java.lang.ExceptionInInitializerError
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.exception.JDBCConnectionException: Error calling DriverManager#getConnection
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.drive_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3307/webpro</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">1122</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<!-- 可选元素 -->
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping resource="com/mine/obj/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>