hibernate學習06
阿新 • • 發佈:2018-12-25
根路徑下建立hibernate.cfg.xml
匯入dtd約束
配置連線資料庫的基本資訊
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- 連線資料庫的基本配置資訊 可參考project資料夾下的etc資料夾下的hibernate.properties檔案 --> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql:///test</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">123456</property> <!-- 額外的配置 --> <property name="hibernate.show_sql">true</property> <property name="hibernate.format_sql">true</property> <!-- 此處表示檢測實體類的對映配置和資料庫表結構,如果不一致則更新表結構 --> <property name="hibernate.hbm2ddl.auto">update</property> <!-- 對映配置 --> <mapping resource="ssh/phoneShop/dao/Users.hbm.xml"/> </session-factory> </hibernate-configuration>
結構化查詢語言的六部分:
ddl ,data definition 定義語言,用來建庫建表,修改表結構
dml,data manipulation ,資料操縱,用來進行插入,刪除,更新
dql,data query,資料查詢,用來查詢資料
dcl,data control ,資料控制,比如授權
ccl,cursor control,遊標控制,比如儲存控制,在資料庫裡遍歷結果集
tql,transaction processing ,事務處理,比如開啟事務,提交事務,儲存事務