日期:2014-05-16  浏览次数:21021 次

Hibernate学习笔记(一)--用MyEclipse 6.5+MySQL 5.0的环境跑起来

准备:建表

用MySQL在名为STMS数据库中建表person

在MyEclipse中建连接数据库的连接名为MySQL_localhost,在Driver JARS中导入MySQL的驱动程序mysql-connector-java-5.1.6-bin.jar

一.新建名为MySQLHibernate的Web Project

File—new—project—MyEclipse—Java Enterprice Projects—Web Project(Optional Maven Support)

在Project Name中输入MySQLHibernate---点击Finsh完成

1xmlversion='1.0'encoding='UTF-8'?> 2DOCTYPEhibernate-configurationPUBLIC 34"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 5 7<hibernate-configuration> 8 9<session-factory> 10 11<propertyname="connection.username">rootproperty> 12 14<propertyname="connection.url"> 15jdbc:mysql://localhost:3306/STMS?useUnicode=true&characterEncoding=GBK 16property> 17 19<propertyname="dialect"> 20org.hibernate.dialect.MySQLDialect 21property> 22 24<propertyname="myeclipse.connection.profile"> 25MySql_localhost 26property> 27 29<propertyname="connection.password">rootproperty