hibernate.cfg.xml 配置

<?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配置的,SessionFactory是Hibernate中的一个类,这个类主要负责保存HIbernate的配置信息,以及对Session的操作 -->
	<session-factory>
		<!--配置数据库的驱动程序,Hibernate在连接数据库时,需要用到数据库的驱动程序 -->
		<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver </property>
		<!--设置数据库的连接url:jdbc:mysql://localhost/hibernate,其中localhost表示mysql服务器名称,此处为本机, 
			hibernate是数据库名 -->
		<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/sxt</property>
		<!--连接数据库是用户名 -->
		<property name="hibernate.connection.username">root</property>
		<!--连接数据库是密码 -->
		<property name="hibernate.connection.password">root</property>
		<!--hibernate.dialect 只是Hibernate使用的数据库方言,就是要用Hibernate连接那种类型的数据库服务器。 -->
		<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect </property>
		<!-- 打印生成的sql语句 -->
		<property name="hibernate.show_sql">true</property>

		<!--指定映射文件为“hibernate/ch1/UserInfo.hbm.xml” -->
		<mapping resource="com/sxt/beans/User.hbm.xml" />


	</session-factory>
</hibernate-configuration>

猜你喜欢

转载自blog.csdn.net/qq_39387571/article/details/78835124
今日推荐