5.2.3数据库连接
部分代码如下:
<!--配置JDBC连接属性--> <property
name="myeclipse.connection.profile">com.mysql.jdbc.Driver</property>
<property
name="connection.url">jdbc:mysql://localhost:3306/db_eshop?useUnicode=true&characterEncoding=gb2312</property>
<property name="ername">root</property> <property name="connection.password">123456</property> <property
name="connection.driver_class">com.mysql.jdbc.Driver</property> <property
name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- 解决HQL查询中直接使用中文的问题 -->
<property name="hibernate.query.factory_class">
org.hibernate.hql.classic.ClassicQueryTranslatorFactory </property>
<!-- 配置C3P0连接池属性 -->
<property name="hibernate.connection.provider_class"> org.hibernate.connection.C3P0ConnectionProvider </property>
<property name="hibernate.c3p0.max_size">20</property> <property name="hibernate.c3p0.min_size">5</property> <property name="hibernate.c3p0.timeout">50000</property> <property
name="hibernate.c3p0.max_statements">100</property> <property
name="hibernate.c3p0.idle_test_period">3000</property>
<!-- 在控制台显示SQL语句 -->
<property name="show_sql">true</property>
<!-- 注册ORM映射文件 -->
<mapping resource="com/ORM/Memberlevel.hbm.xml" /> <mapping resource="com/ORM/Merchandise.hbm.xml" /> <mapping resource="com/ORM/Admin.hbm.xml" /> <mapping resource="com/ORM/Orders.hbm.xml" />
<mapping resource="com/ORM/Cartselectedmer.hbm.xml" /> <mapping resource="com/ORM/Cart.hbm.xml" />