NHibernate各种数据库连接参数文件配置方法说明

时间:2021-12-25 13:44:31

//NHibernate各种数据库连接参数文件配置方法说明

//配置文件Config/Hibernate.cfg.xml内容如下所示: 
<?xml version="1.0" encoding="utf-8" ?> 
<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" > 
  <session-factory name="CwfServer"> 
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> 
 <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property> 
    <property name="connection.connection_string">server=192.168.1.244;database=wf_db_t;uid=sa;pwd=supersit.1;</property> 
 <property name="adonet.batch_size">10</property> 
    <property name="show_sql">true</property> 
    <property name="command_timeout">60</property> 
    <property name="hbm2ddl.auto">update</property> 
    <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property> 
    <!--<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>--> 
    <mapping assembly="Net.NHibernateDB"/> 
    <mapping assembly="Cwfapi"/> 
    <mapping assembly="CwfEngine"/> 
  </session-factory> 
</hibernate-configuration> 
其中:具体数据库需要修改的地方说明如下: 
========================================================================================= 
SQLServer配置方法: 
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> 
<property name="connection.driver_class">NHibernate.Driver.Sql2008ClientDriver</property> 
------------------------------ 
<property name="dialect">NHibernate.Dialect.MsSql7Dialect</property> 
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property> 
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> 
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property> 
<property name="dialect">NHibernate.Dialect.MsSql2012Dialect</property> 
------------------------------ 
<property name="connection.connection_string">server=192.168.1.244;database=wf_db_t;uid=sa;pwd=supersit.1;</property> 
=========================================================================================

Oracle配置方法: 
<property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property> 
------------------------------ 
<property name="dialect">NHibernate.Dialect.Oracle8iDialect</property> 
<property name="dialect">NHibernate.Dialect.Oracle9iDialect</property> 
<property name="dialect">NHibernate.Dialect.OracleLiteDialect</property> 
<property name="dialect">NHibernate.Dialect.Oracle10gDialect</property> 
------------------------------ 
<property name="connection.connection_string">server=oracle244;uid=wf_db;pwd=1;</property> 
=========================================================================================

MySQL配置方法: 
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property> 
------------------------------ 
<property name="dialect">NHibernate.Dialect.MySQLDialect</property> 
<property name="dialect">NHibernate.Dialect.MySQL5Dialect</property> 
------------------------------ 
<property name="connection.connection_string">server=192.168.1.244;database=wf_db;uid=wf_db;pwd=1;</property> 
=========================================================================================

SQLite配置方法: 
<property name="connection.driver_class">NHibernate.Driver.SQLiteDriver</property> 
<property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property> 
------------------------------ 
<property name="dialect">NHibernate.Dialect.SQLiteDialect</property> 
------------------------------ 
<property name="connection.connection_string">Data Source=c:\wf_db.db3;Version=3;</property> 
=========================================================================================

PostgreSQL配置方法: 
<property name="connection.driver_class">NHibernate.Driver.NpgsqlDriver</property> 
<property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property> 
------------------------------ 
<property name="dialect">NHibernate.Dialect.PostgreSQLDialect</property> 
------------------------------ 
<property name="connection.connection_string">server={0};database={1};uid={2};pwd={3};</property> 
=========================================================================================

MDB Access配置方法: 
<property name="connection.driver_class">NHibernate.Driver.OleDbDriver</property> 
------------------------------ 
<property name="dialect">NHibernate.Dialect.GenericDialect</property> 
------------------------------ 
<property name="connection.connection_string">Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};</property> 
=========================================================================================

DB2配置方法: 
<property name="connection.driver_class">NHibernate.Driver.DB2Driver</property> 
<property name="connection.driver_class">NHibernate.Driver.DB2400Driver</property> 
------------------------------ 
<property name="dialect">NHibernate.Dialect.DB2Dialect </property> 
<property name="dialect">NHibernate.Dialect.DB2400Dialect </property> 
------------------------------ 
<property name="connection.connection_string">UID=db2admin;PWD=1;Database=SAMPLE;Server=SHARK-LABTOP:50000 
</property> 
=========================================================================================

Informix配置方法: 
<property name="connection.driver_class">NHibernate.Driver.IfxDriver</property> 
------------------------------ 
<property name="dialect">NHibernate.Dialect.InformixDialect </property> 
<property name="dialect">NHibernate.Dialect.InformixDialect0940</property> 
<property name="dialect">NHibernate.Dialect.InformixDialect1000</property> 
------------------------------ 
<property name="connection.connection_string">Host={0};Service={1};Server={2};Database={3};User id={4};Password={5};</property> 
========================================================================================= 
---the---end---