季浩的Blog
努力
BlogJava
首頁
新隨筆
聯(lián)系
聚合
管理
隨筆-46 評論-64 文章-2 trackbacks-0
Hibernate基礎(chǔ) - 配置
Hibernate 提供了一個(gè)hibernate.properties的模板,稍加修改就能得到自己想要的配置效果
下面這一段XML配置文件中關(guān)于數(shù)據(jù)庫連接方式的配置,可以在hibernate.properties中完成
<?
xml?version="1.0"?encoding="UTF-8"
?>
<!
DOCTYPE?hibernate-configuration?PUBLIC
????????"-//Hibernate/Hibernate?Configuration?DTD?3.0//EN"
????????"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"
>
<
hibernate-configuration
>
????
<
session-factory?
name
="sf"
>
????
<!--
?
????????<property?name="hibernate.connection.driver_class">
????????????org.hsqldb.jdbcDriver
????????</property>
????????<property?name="hibernate.connection.url">
????????????jdbc:hsqldb:hsql://localhost/HibernateMapping
????????</property>
????????<property?name="hibernate.connection.username">sa</property>
????????<property?name="hibernate.dialect">
????????????org.hibernate.dialect.HSQLDialect
????????</property>
?????
-->
????????
<
mapping?
package
="cn.heapstack.models"
?
/>
????????
<
mapping?
class
="cn.heapstack.models.User"
?
/>
????????
<
mapping?
class
="cn.heapstack.models.UserInfo"
?
/>
????
</
session-factory
>
????
</
hibernate-configuration
>
##?HypersonicSQL
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
hibernate.dialect?org.hibernate.dialect.HSQLDialect
hibernate.connection.driver_class?org.hsqldb.jdbcDriver
hibernate.connection.username?sa
hibernate.connection.password
hibernate.connection.url?jdbc:hsqldb:hsql://localhost/HibernateMapping
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
代碼示例:
Configuration?cfg?
=
?
new
?AnnotationConfiguration().configure(
"
./hibernate.cfg.xml
"
);
SessionFactory?sf?
=
?cfg.buildSessionFactory();
Session?session?
=
?sf.openSession();
org.hibernate.Transaction?tx
=
?session.beginTransaction();
tx.commit();
session.close();
posted on 2007-10-26 14:40
jht
閱讀(301)
評論(1)
編輯
收藏
所屬分類:
Hibernate
評論:
#
re: Hibernate基礎(chǔ) - 配置
2011-09-02 09:01 |
tb
剛好能用上
回復(fù)
更多評論
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
讀書:
《JAVA與模式》閻宏
《精通正則表達(dá)式》
《Perl語言入門》
《J2EE Development without EJB》
BlogJava-季浩的Blog
100.0%男性傾向,0.0%女性傾向
評點(diǎn):您的文風(fēng)冷靜而鎮(zhèn)定,言語間展現(xiàn)出強(qiáng)悍的思辨能力與恢宏的胸襟,一個(gè)男子漢的陽剛形象躍然紙上。
yodao
|
博客男女
很不錯(cuò)的網(wǎng)站,在線沖手機(jī)費(fèi)
<
2007年10月
>
日
一
二
三
四
五
六
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(2)
給我留言
查看公開留言
查看私人留言
隨筆分類
DWR(2)
Eclipse(2)
Groovy&Grails(1)
GWT(1)
Hibernate(1)
J2EE(7)
J2ME(4)
J2SE(14)
OSGI(2)
Pattern
Spring
Struts1(1)
Struts2(2)
Swing Tips(5)
數(shù)獨(dú)程序(1)
隨筆檔案
2008年9月 (7)
2008年8月 (3)
2008年7月 (3)
2008年5月 (2)
2008年4月 (1)
2008年3月 (1)
2008年1月 (2)
2007年11月 (2)
2007年10月 (2)
2007年9月 (4)
2007年8月 (1)
2007年7月 (2)
2007年5月 (1)
2007年3月 (4)
2007年1月 (4)
2006年12月 (3)
2006年3月 (1)
2006年2月 (2)
文章檔案
2008年7月 (1)
2008年4月 (1)
我的BLOG
我的.NET和其他相關(guān)主題Blog
我的C/C++博客
搜索
積分與排名
積分 - 104217
排名 - 560
最新評論
1.?re: 使用JSON和AJAX創(chuàng)建網(wǎng)站的標(biāo)簽云(TagCloud)
頂
--fffr
2.?re: Q:為什么透明的PNG格式圖片在網(wǎng)頁里顯示的時(shí)候不是透明的?
因?yàn)槟愕木W(wǎng)頁背景
--shndpz
3.?re: 使用WebService 和RMI遠(yuǎn)程協(xié)作
實(shí)現(xiàn)類沒有找到
--11
4.?re: Groovy Plugin for Eclipse IDE
安裝后,新建菜單里看不到Groovy Project的選項(xiàng)?
--雷納德
5.?re: Q: response.setHeader("Cache-Control","no-cache"); 是干什么用的?目的是什么?
我個(gè)人認(rèn)為是不緩存或者保存你這次返回的信息,
比如我們在網(wǎng)頁上生成圖片,但不希望這些圖片一直占據(jù)內(nèi)存,就可以使用這個(gè)策略吧。
--kaki
閱讀排行榜
1.?Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location](17174)
2.?Q: response.setHeader("Cache-Control","no-cache"); 是干什么用的?目的是什么?(16596)
3.?[JSP] The function *** cannot be located with the specified prefix(7771)
4.?[DWR]Max depth exceeded when dereferencing(4225)
5.?[DWR] --Erroring: batchId[1] message[org.directwebremoting.extend.MarshallException: Error marshalling ...(4207)
評論排行榜
1.?Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) - [unknown location](11)
2.?設(shè)計(jì)模式學(xué)習(xí)(一) 工廠模式之簡單工廠(7)
3.?[DWR]Max depth exceeded when dereferencing(5)
4.?MyScreenSnap 一個(gè)簡單的截圖程序(5)
5.?[DWR] --Erroring: batchId[1] message[org.directwebremoting.extend.MarshallException: Error marshalling ...(4)
Powered by:
博客園
模板提供:
滬江博客
Copyright ©2025 jht
主站蜘蛛池模板:
涞源县
|
都江堰市
|
丰顺县
|
策勒县
|
凌云县
|
SHOW
|
徐水县
|
进贤县
|
铅山县
|
仙居县
|
嘉祥县
|
南平市
|
平山县
|
元朗区
|
柳江县
|
泰宁县
|
察哈
|
吉水县
|
西畴县
|
南安市
|
保康县
|
佛学
|
双辽市
|
合山市
|
宽城
|
肥乡县
|
光泽县
|
淮南市
|
德安县
|
萍乡市
|
靖西县
|
都兰县
|
夹江县
|
巴马
|
千阳县
|
浠水县
|
玉山县
|
庆安县
|
固安县
|
清镇市
|
武夷山市
|