生活随笔
收集整理的這篇文章主要介紹了
hibernate连接数据库配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
hibernate連接數據庫配置
1.連接mySql,文件配置如下:?
<?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>?
<property name="connection.url">? jdbc:mysql://localhost:3306/test?
</property>?
<property name="connection.username">sa
</property>?
<property name="connection.password">sa123
</property>?
<property name="connection.driver_class">com.mysql.jdbc.Driver?
</property>?
<property name="dialect">?org.hibernate.dialect.MySQLDialect?
</property>?
<property name="show_sql">true
</property>?
</session-factory>?
</hibernate-configuration>?
2.連接Oracle,文件配置如下:?
<?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>?
<property name="connection.url">jdbc:oracle:thin:@127.0.0.1:1521:test
</property>?
<property name="connection.username">sa
</property>?
<property name="connection.password">sa123
</property>?
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver
</property>?
<property name="dialect">org.hibernate.dialect.Oracle9Dialect
</property>?
<property name="show_sql">true
</property>?
</session-factory>?
</hibernate-configuration>?
3.連接sqlServer,文件配置如下:?
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 5.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-5.0.dtd"> <hibernate-configuration> <session-factory> <property name="connection.url">jdbc:sqlserver://127.0.0.1:1433;databaseName=test
</property> <property name="connection.username">sa
</property> <property name="connection.password">sa123
</property> <property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver
</property> <property name="dialect">org.hibernate.dialect.SQLServerDialect
</property> <property name="show_sql">true
</property> <mapping resource="com/hhl/entity/user.hbm.xml"/> </session-factory> </hibernate-configuration> 4.hibernate各類工具包在官網下載即可
原文地址https://blog.csdn.net/urey12138/article/details/81239114
總結
以上是生活随笔為你收集整理的hibernate连接数据库配置的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。