NHibernate连接Oracle10g配置问题
来源:互联网 发布:手机端淘宝店铺模板 编辑:程序博客网 时间:2024/05/16 18:57
<!--NHibernate配置--> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory name="ora10gFactory"> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider, NHibernate</property> <!--property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property--> <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property> <property name="connection.connection_string"> User ID=fiocoa;Password=fiocoa123;Data Source=ora10g </property> <property name="show_sql">false</property> <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property> <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property> <property name="current_session_context_class">managed_web</property> <property name="proxyfactory.factory_class">NHibernate.Bytecode.DefaultProxyFactoryFactory,NHibernate</property> <property name="hbm2ddl.keywords">none</property> <!--加载映射--> <mapping assembly="Enterprise.Model.Basis"/> </session-factory> </hibernate-configuration>
一修改dialect为NHibernate.Dialect.Oracle10gDialect,(我用的是oracle10g)原来的为NHibernate.Dialect.OracleDialect,不修改会提示映射文件不能编译,这个错误有点奇怪。
二增加mapping节点,来指定映射文件所在程序集
好了,简单的写个测试程序,再测试一下,OK测试能过。
我们看到在配置文件中有一行:<!-- This is the System.Data.OracleClient.dll provider for Oracle from MS -->,这里使用的是微软提供的驱动程序,我们改成Oracle提供的试试。在配置文件中把NHibernate.Driver.OracleClientDrivern改成NHibernate.Driver.OracleDataClientDrivern。OK再测试,提示“Could not create the driver from NHibernate.Driver.OracleDataClientDriver.”,应该是我们没有添加Oracle.DataAccess的引用,我们来添加引用,很奇怪在添加程序集的窗口中的.Net选项卡,找不到,没有关系,我们在浏览选项卡里找,在“X:\oracle\product\10.2.0\client_1\BIN”目录下找到并选择Oracle.DataAccess.dll,再来做测试。还是提示“Could not create the driver from NHibernate.Driver.OracleDataClientDriver.”,我们找到Oracle.DataAccess.dll,拷贝到测试程序的bin目录下,再运行。这次还是报错,不过错误提示变了,“Unable to cast object of type 'Oracle.DataAccess.Client.OracleConnection' to type 'System.Data.Common.DbConnection'.”,上网google了好久,没有找到解决办法,后来看到园友1-2-3在用NHibernate调用Oracle的存储过程 这篇文章找到了解决办法,在配置文件中增加一行:“<property name="hbm2ddl.keywords">none</property>”,再次执行我们的测试程序,这次执行通过。
微软和Oracle都提供了.net连接Oracle数据库的驱动程序,一般认为Oracle所提供的驱动程序性能上要优于微软提供的。在.net4.0中使用System.Data.OracleClient时,会得到警告信息:“'System.Data.OracleClient.OracleConnection' is obsolete: 'OracleConnection has been deprecated. http://go.microsoft.com/fwlink/?LinkID=144260' ”,在给出的这个链接上有这么一句话:“The types in System.Data.OracleClient are deprecated. The types are supported in version 4 of the .NET Framework but will be removed in a future release. Microsoft recommends that you use a third-party Oracle provider.”意思是System.Data.OracleClient是不再被推荐使用的,并且在4.0以后的版本将被移除,微软推荐你使用Oracle提供的驱动程序。
- NHibernate连接Oracle10g配置问题
- hibernate和oracle10g连接配置问题
- nhibernate连接池配置
- oracle10g配置远程连接
- hibernate连接oracle10g配置
- oracle10g配置远程连接
- NHibernate连接Acess数据库配置
- 工作问题:连接Oracle10G 问题
- sqlplus 连接oracle10g 乱码问题
- Oracle10g配置em的问题
- tomcat5.5+oracle10g数据连接池配置
- 配置Power Designer连接Oracle10g数据库
- Oracle10g客户端连接远程数据库配置图解
- delphi7读取ini配置连接oracle10G
- Oracle10g客户端连接远程数据库配置图解
- PLSQL Developer连接oracle10g的问题
- myeclipse6.0 连接oracle10g的问题
- ORACLE10G客户端与服务器端的连接问题
- SQLServer中数据库文件的存放方式,文件和文件组
- HTML5的未来 - HTML5 还能走多远?
- alsa播放音频类
- 虚拟座谈会:专家眼中的QA、敏捷测试、探索式测试及测试的开放性
- Memcached 集群架构方面的问题
- NHibernate连接Oracle10g配置问题
- 关于ssh证书访问git仓库时的权限问题
- Windows窗口相关的一些概念解释 (
- GCD实战2:资源竞争
- 设置git commit 模板
- 在android使用mina实现网络访问
- ALG_ulawDecode音频解码函数
- 改变UITextField placeHolder颜色、字体
- 导出Excel技术总结(3)