hibernate.connection.driver_class=屬性值
採用Java屬性檔案格式的組態檔時,指定 connection.driver_class 屬性。資料庫 | 驅動類 |
---|---|
DB2 | COM.ibm.db2.jdbc.app.DB2Driver |
PostgreSQL | org.postgresql.Driver |
MySql | com.mysql.jdbc.Driver |
Oracle | oracle.jdbc.driver.OracleDriver |
Sybase | com.sybase.jdbc2.jdbc.SybDriver |
Microsoft SQL Server | com.microsoft.jdbc.sqlserver.SqlServerDriver |
SAP DB | com.sap.dbtech.jdbc.DriverSapDB |
Informix | com.Informix.jdbc.IfxDriver |
HypersonicSQL | org.hsqldb.jdbcDriver |
Mckoi SQL | com.mckoi.JDBCDriver |
Interbase | interbase.interclient.Driver |
Pointbase | com.pointbase.jdbc.jdbcUniversalDriver |
<property name="hibernate.connection.driver_class"> com.microsoft.jdbc.sqlserver.SQLServerDriver </property>
hibernate.connection.driver_class=com.microsoft.jdbc.sqlserver.SQLServerDriver
<property name="hibernate.connection.driver_class"> com.mysql.jdbc.Driver </property>
hibernate.connection.driver_class=com.mysql.jdbc.Driver
<property name="hibernate.connection.driver_class"> oracle.jdbc.driver.OracleDriver </property>
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
<?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="dialect">org.hibernate.dialect.DerbyDialect</property><!-- 設定查詢SQL語句使用方言--> <!--設定連線資料庫URL--> <property name="connection.url">jdbc:sqlserver://localhost:1433;DatabaseName= db_database11</property> <property name="connection.username">sa</property> <!--設定連線資料庫使用者名稱--> <property name="connection.password"></property><!--設定連線資料庫密碼--> <!--載入資料庫驅動--> <property name="connection.driver_class">com.microsoft.sqlserver.jdbc. SQLServerDriver</property> <property name="myeclipse.connection.profile">MyEclipse Derby</property> </session-factory> </hibernate-configuration>控制台輸出結果如下: