从NHibernate连接到MySQL时出现问题 [英] Problem connecting to MySQL from NHibernate

查看:104
本文介绍了从NHibernate连接到MySQL时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将NHibernate 3.0与MySQL用作数据库.在我的本地主机上,我可以连接到数据库并执行我想做的所有事情.但是,每当我将文件上传到生产服务器时,都会出现错误,指出:

I am using NHibernate 3.0 with MySQL as the database. On my localhost, I can connect to the database and do everything I want to. However, whenever I upload the files to the production server, I get an error which states:

建立与SQL Server的连接时发生与网络有关或特定于实例的错误.找不到服务器或无法访问该服务器.请验证实例名称正确并且将SQL Server配置为允许远程连接. (提供者:SQL网络接口,错误:26-指定服务器/实例时出错)"

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"

web.config文件包含以下部分:

The web.config file has the following section:

<hibernate-configuration xmlns="urn:nhibernate-configuration">    
<session-factory >
  <property name="connection.provider" specificversion="false">NHibernate.Connection.DriverConnectionProvider</property>
  <property name="connection.driver_class" specificversion="false">NHibernate.Driver.MySqlDataDriver</property>
 <!--<property name="connection.connection_string" specificversion="false">
    Data Source=localhost;Port=3306;Database=sampledb;Uid=myuser;Pwd=mypass
    DSN=mydsn;UID=myuser;PWD==mypass
  </property>-->
  <property name="connection.connection_string">
    Server=localhost;Database=sampledb;User ID=myuser;Password=mypass;
  </property>
  <property name="proxyfactory.factory_class" specificversion="false">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>      
  <property name="dialect" specificversion="false">NHibernate.Dialect.MySQLDialect</property>      
  <property name="hbm2ddl.keywords" specificversion="false">none</property>
  <mapping assembly="App_Code.NHibernateHelpers" />
</session-factory>
</hibernate-configuration>

我什至在上面显示的注释部分中尝试了连接字符串,但似乎没有任何作用...但是所有这些都在我的本地计算机上起作用.有人可以告诉我我可能会想念什么吗?我的生产服务器是运行.NET 2.x和MySQL连接器5.0.9的Windows 2003服务器.

I have even tried the connection strings in the commented section shown above but nothing seems to work...yet all those work on my local machine. Can someone please tell me what I may be missing? My production server is a Windows 2003 server running .NET 2.x and MySQL connector 5.0.9.

谢谢.

推荐答案

再次检查是否使用了正确的web.config.错误中提到的SQL Server是MS SqlServer,而不是mysql.

Double check that the correct web.config is used. SQL Server as mentioned in you error is MS SqlServer and not mysql.

您忘记将其添加到web.config吗?

Have you forgot to add this to your web.config?

<configSections>
  <section name="hibernate-configuration"
  type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>

这篇关于从NHibernate连接到MySQL时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆