<?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> <!-- 配置数据库连接 connection --> <session-factory> <!-- 数据库驱动 --> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <!-- 数据库地址 localhost可以写作 jdbc:mysql:/// --> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/database_name</property> <!-- 数据库用户名 --> <property name="hibernate.connection.username">username</property> <!-- 数据库用户的密码 --> <property name="hibernate.connection.password">password</property> <!-- 数据库方言 MySQL --> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <!-- 连接池 C3P0 --> <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> <!-- 格式化输出生成的SQL语句 --> <property name="hibernate.show_sql">true</property> <property name="hibernate.format_sql">true</property> <!-- 加载映射文件 --> <mapping resource="package.name.ClassName.hbm.xml" /> </session-factory> </hibernate-configuration>
原文:https://www.cnblogs.com/engreal/p/10544365.html