Hibernate的配置檔案

2021-06-19 16:53:55 字數 1330 閱讀 3729

必選項:

hibernate.connection.username:訪問的資料庫使用者名稱

hibernate.connection.password:訪問的資料庫密碼

hibernate.connection.url:連線資料庫的url

hibernate.connection.driver_class:連線資料庫使用的驅動程式

hibernate.dialect:連線資料庫所使用的方言

可選項:

show_sql:顯示執行的sql語句

常見資料庫的驅動程式、url、方言

1.mysql

驅動程式為:"com.mysql.jdbc.driver", url為:"jdbc:mysql://localhost:3306/[dbname]"。方言:org.hibernate.dialect.mysqldialect

2.oracle

驅動程式為:"oracle.jdbc.driver.oracledriver", url為:"jdbc:oracle:thin:@[ip]:1521:[dbname]「方言:org.hibernate.dialect.oracledialect

3.sql server

驅動程式為:"com.microsoft.jdbc.sqlserver.sqlserverdriver", url為:"jdbc:microsoft:sqlserver://[ip]:1433;databasename=[dbname],方言:org.hibernate.dialect.sqlserverdialect

mysql的乙個配置樣例

<?xml version='1.0' encoding='utf-8'?>

org.hibernate.dialect.mysqldialect

jdbc:mysql://localhost/test

com.mysql.jdbc.driver

root

hantrue

oracle的乙個配置樣例

<?xml version='1.0' encoding='utf-8'?>

org.hibernate.dialect.oracledialect

jdbc:oracle:thin:@10.105.240.9:1521:orcl

oracle.jdbc.driver.oracledriver

grp_9_7

grp97

true

org.hibernate.hql.classic.classicquerytranslato***ctory

Hibernate的配置檔案

對ehibernate的核心配置檔案可以有兩種 hibernate.cfg.xml hibernate.properties 編碼實現 configuration config new configuration addresource hbm.xml 核心配置檔案hibernate.cfg.xml...

Hibernate的配置檔案配置

hiebernate一共有兩種方式,xml檔案配置和注釋配置,這裡就只講第一種配置方式 xml配置檔案配置,而xml檔案配置需要配置兩個檔案,分別是hibernate.cfg.xml和 hbm.xml 這個 是和實體類名一樣的,例如customer的實體類,如下 public class custo...

Hibernate主配置檔案

主配置hibernate.cfg.xml 一.配置的key前面的hibernate.字首可有可無 二.按作用分為三類 1.資料庫資訊 五個配置資訊 方言 驅動 url username password org.hibernate.dialect.mysqldialect jdbc mysql hi...