隨筆-46  評論-64  文章-2  trackbacks-0
          Hibernate 提供了一個hibernate.properties的模板,稍加修改就能得到自己想要的配置效果

          下面這一段XML配置文件中關于數據庫連接方式的配置,可以在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 閱讀(303) 評論(1)  編輯  收藏 所屬分類: Hibernate

          評論:
          # re: Hibernate基礎 - 配置 2011-09-02 09:01 | tb
          剛好能用上   回復  更多評論
            

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          Locations of visitors to this page
          讀書:
          《JAVA與模式》閻宏
          《精通正則表達式》
          《Perl語言入門》
          《J2EE Development without EJB》
          BlogJava-季浩的Blog
          100.0%男性傾向,0.0%女性傾向
          評點:您的文風冷靜而鎮定,言語間展現出強悍的思辨能力與恢宏的胸襟,一個男子漢的陽剛形象躍然紙上。
          yodao | 博客男女

          很不錯的網站,在線沖手機費
          <2007年10月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章檔案

          我的BLOG

          搜索

          •  

          積分與排名

          • 積分 - 104292
          • 排名 - 560

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 濮阳县| 邛崃市| 靖安县| 通江县| 新田县| 万荣县| 西乌| 巴东县| 元朗区| 金阳县| 昆山市| 越西县| 大英县| 土默特右旗| 镇安县| 嘉荫县| 荔浦县| 新和县| 客服| 白城市| 通州市| 晋中市| 新平| 南华县| 永川市| 茂名市| 开化县| 藁城市| 佛冈县| 玉环县| 库车县| 闽清县| 湄潭县| 虹口区| 资源县| 新竹县| 通许县| 临高县| 富川| 海淀区| 乌审旗|