使用Hibernate 4.0的包。
方法一 (我没有试):
在src目录下添加hibernate.properties配置文件,内容如下:
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.password=634587
hibernate.connection.url=jdbc:mysql://localhost:3306/test
hibernate.connection.username=root
hibernate.dialect=org.hibernate.dialect.MySQLDialect
方法二(我已成功):
将
SessionFactory sf = cfg.buildSessionFactory(
new
ServiceRegistryBuilder().buildServiceRegistry());
|
替换成
SessionFactory sf =
.buildServiceRegistry());
|
http://www.cnblogs.com/cnscoo/archive/2012/09/17/2689021.html
本文介绍使用Hibernate 4.0进行数据库连接配置的方法。提供了两种配置SessionFactory的方式,一种是通过properties文件,另一种是在代码中直接设置。
2400

被折叠的 条评论
为什么被折叠?



