1.创建一个新项目first
2.加载数据库和hibernate驱动,方法:
a.在项目名上点右键->属性->path->required libraries->add->如果列表中有所要的包,则直接选择->OK
b.在项目名上点右键->属性->path->required libraries->add->如果列表中没有所要的包,则直接选择->NEW->ADD->选择包所在路径-
>OK->在name框中输入包名字->OK->OK->OK
C.注意,在选择包前,一定要将包复制到JBuilder的thirdparty目录
3.在项目名上点右键->属性->build->resource->在右边的文件类型列表中选择XML,再选择COPY->ok
4.创建虚拟目录,file->new...->web->web module
5.在项目根目录下(project source)创建hibernate.cfg.xml和tb_users.hbm.xml配置文件
hibernate.cfg.xml
6.在项目根目录下(project source)创建HibernateUtil.java(hibernate连接类)和Users.java(数据操作类)
HibernateUtil.java
7.java hibernate配置
命令:
java net.sf.hibernate.tool.hbm2java.codegenerator tb_users.hbm.xml
配置文件:
D:\Borland\JBuilder2005\jdk1.4\lib\tools.jar;D:\Borland\JBuilder2005\jdk1.4\lib\dt.jar;D:\Borland\JBuilder2005\jdk1.4
\jre\lib\rt.jar;D:\Borland\JBuilder2005\thirdparty\hibernate\hibernate-tools.jar;D:\Borland\JBuilder2005
\thirdparty\hibernate\commons-collections-2.1.1.jar;D:\Borland\JBuilder2005\thirdparty\hibernate\commons-lang-
2.0.jar;D:\Borland\JBuilder2005\thirdparty\hibernate\commons-logging-1.0.4.jar;D:\Borland\JBuilder2005
\thirdparty\hibernate\hibernate2.jar;D:\Borland\JBuilder2005\thirdparty\hibernate\jdom.jar