自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

描述Hibernate MySql連接配置

開發(fā) 后端
這里介紹Hibernate MySql連接配置,在Hibernate中,可以配置很多種數(shù)據(jù)庫,例如MySql、Sql Server和Oracle,Hibernate MySql連接配置。

本文向大家介紹Hibernate,可能好多人還不了解Hibernate MySql連接配置,沒有關系,看完本文你肯定有不少收獲,希望本文能教會你更多東西。

Hibernate MySql連接配置

在Hibernate中,可以配置很多種數(shù)據(jù)庫,例如MySql、Sql Server和Oracle,Hibernate MySql連接配置舉例如下:

Hibernate.cfg.xml

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <!DOCTYPE hibernate-configuration PUBLIC  
  3. "-//Hibernate/Hibernate Configuration DTD 3.0//EN"  
  4. "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 
  5. <hibernate-configuration> 
  6. <session-factory> 
  7. <!-- 各屬性的配置--  
  8. <!—為true表示將Hibernate發(fā)送給數(shù)據(jù)庫的sql顯示出來 --> 
  9. <property name="show_sql">true</property> 
  10. <!-- SQL方言,這邊設定的是MySQL --> 
  11. <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property> 
  12. <!-- 一次讀的數(shù)據(jù)庫記錄數(shù) --> 
  13. <property name="jdbc.fetch_size">50</property> 
  14. <!-- 設定對數(shù)據(jù)庫進行批量刪除 --> 
  15. <property name="jdbc.batch_size">30</property> 
  16. <!--驅(qū)動程序--> 
  17. <property name="connection.driver_class">com.mysql.jdbc.Driver</property> 
  18. <!-- JDBC URL --> 
  19. <property name="connection.url">jdbc:mysql:
  20. //localhost/dbname?characterEncoding=gb2312</property> 
  21. <!-- 數(shù)據(jù)庫用戶名--> 
  22. <property name="connection.username">root</property> 
  23. <!-- 數(shù)據(jù)庫密碼--> 
  24. <property name="connection.password">root</property> 
  25. <!—映射文件 --> 
  26. <mapping resource="com/amigo/pojo/User.hbm.xml"/> 
  27. <mapping resource="com/amigo/pojo/Org.hbm.xml"/> 
  28. </session-factory> 
  29. </hibernate-configuration> 

上面使用的驅(qū)動類是com.mysql.jdbc.Driver.需要將MySql的連接器jar包(eg. mysql-connector-java-5.0.4-bin.jar)加入到classpath中。

【編輯推薦】

  1. 淺析Hibernate orm框架
  2. Hibernate Callback簡單概括
  3. 概述Hibernate dbcp連接池使用方法
  4. Hibernate Shard三種策略剖析
  5. 討論Hibernate和模型對象
責任編輯:佚名 來源: 新浪科技
相關推薦

2009-06-15 13:46:00

netbeans配置hibernate

2009-09-27 17:05:02

Hibernate p

2009-09-23 14:00:07

Hibernate連接

2009-09-22 12:45:00

Hibernate性能

2009-09-28 15:43:42

Hibernate O

2009-09-23 17:34:18

Hibernate映射

2009-09-23 10:58:32

Hibernate T

2009-09-21 16:30:20

Hibernate S

2009-09-22 16:04:50

Hibernate連接

2009-09-22 11:16:27

Hibernate經(jīng)驗

2009-09-22 17:41:07

Hibernate性能

2009-09-27 13:00:56

Hibernate S

2009-09-29 16:48:42

Hibernate J

2009-06-17 16:22:45

Hibernate連接

2012-02-07 13:27:03

HibernateJava

2009-09-24 13:17:37

Hibernate類庫

2009-09-23 10:23:03

Hibernate檢查

2009-09-21 17:46:34

Hibernate持久

2009-09-29 10:57:25

設置Hibernate

2009-09-21 13:56:09

Hibernate3.
點贊
收藏

51CTO技術(shù)棧公眾號