(采用的是hibernate中XML配置方式连接数据库,以后在更新其他方式的连接)
Hibernate就是Java后台数据库持久层的框架,也是目前企业用最多的数据库框架,主要是基于ORM -- object relationship Mapping,翻译成中文叫“对象关系映射”,也就是将SQL这种非面向对象语言转化成hibernation面向对象的写法,本文将通过在Eclipse下搭建HIbernate框架
我所使用的Hibernate版本是Hibernate3.3.2,Hibernate官网下载www.hibernate.org
下面开始搭建hibernate数据库:
1.在eclipse中新建Java project项目,名称为:hibernateTest。右击项目名称,点击property,选择Java Build Path,加入需要导入的JAR包。
2.在src文件夹下,新建hibernate.cfg.xml配置文件,(连接数据库的参数信息)
hibernate.cfg.xml文件代码如下:
/p>
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/test
root
123456
true
org.hibernate.dialect.MySQLDialect
thread<