1.创建表
create table customers(
id int primary key ,
name varchar(20),
age int,
birthday date,
married int ,
photo longblob,
description text
)
注:
1.oracle
photo blob,
description clob
2.sqlserver:
photo image,
description text
2.创建java项目
3.添加类库
hibernate:${hibernate解压目录}/lib/required/*.jar + hibernate3.jar
Driver.jar(mysql)
Log4j.jar和slf4j.jar
4.创建java类.
5.创建映射文件Customer.hbm.xml,需要和Customer放在一起.
dtd:${hibernate3.jar}/org.hibernate/hibernate-mapping3.0.dtd/3行.
6.创建src/hibernate.properties
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost:3306/hibernate
hibernate.connection.username=root
hibernate.connection.password=root
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql=true
7.创建App程序.
本文介绍使用Hibernate框架实现客户信息表的映射过程,包括创建数据库表、配置Java类及映射文件,并演示如何通过Hibernate操作数据。

1057

被折叠的 条评论
为什么被折叠?



