转载自 https://blog.csdn.net/chentiefeng521/article/details/58775415
Hibernate中配置文件默认命名为hibernate.cfg.xml,下面就列出了连接三种数据库时(SQL Server、Oracle、MySQL),hibernate.cfg.xml的一些必要配置。
使用SQL Server配置
1 <?xml version='1.0' encoding='UTF-8'?>
2
3
5 "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
6
7 "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
8
9
10
11
12
13
14
15 jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=db_manpower
16
17
18
19 com.microsoft.jdbc.sqlserver.SQLServerDriver
20
21
22
23 sa
24
25
26
27
28
29
30
31 ture
32
33
34
35 org.hibernate.dialect.SQLServerDialect
36
37
38
39 16
40
41
42
43
44
45
46
47
使用MySql的配置
/p>
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/mysqldb
root
admin
1
org.hibernate.dialect.MySQLDialect
true
true
使用Oracle的配置
hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:@127.0.0.1:1521:DBSQL
PERSONNEL_MANAGE
MWQ
org.hibernate.dialect.OracleDialect
true
true
true