zoukankan      html  css  js  c++  java
  • SQL Server改MySQL注意事项

    主要是NHibernate连接MySQL注意事项:

    1. 在website的bin目录里添加MySql.Data.dll(可在官方下载)和hibernate.cfg.xml
    2. 启用新的OpenSession()方法
    3. 通过ADO连接数据库的方式会出现“用户名root无法登陆”的错误提示。所以全部通过NHibernate连接,使用NHibernate的函数。
    4. 在电脑上安装MySql的时候注意选择“Developer Machine”.要不然会出现无法启动MySql服务的错误:
    5. T-SQL和MySql一些常见的不兼容。
      • top 10 -> limit index,length
      • dbo. -> 空
      • getDate() -> NOW()
      • DATEADD(mi,15,GETDATE()) -> DATE_ADD(NOW(), INTERVAL 15 MINUTE)
      • .....

    参考:

      1. hibernate.cfg.xml

    <?xml version="1.0" encoding="utf-8"?>
    <!--
    This template was written to work with NHibernate.Test.
    Copy the template to your NHibernate.Test project folder and rename it in hibernate.cfg.xml and change it
    for your own use before compile tests in VisualStudio.
    -->
    <!-- This is the ByteFX.Data.dll provider for MySql -->
    <hibernate-configuration  xmlns="urn:nhibernate-configuration-2.0" >
        <session-factory>
        <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
            <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
            <property name="connection.connection_string">
                Database=clientsystem_dbo;Data Source=127.0.0.1;User Id=root;Password=123456
            </property>
        
        <property name="dialect">NHibernate.Dialect.MySQLDialect</property>
            <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>  
        <property name="hbm2ddl.keywords">none</property>

      </session-factory>
    </hibernate-configuration>

    1. OpenSession()       //MySql 初始化session配置
              public static ISession OpenSession()
              {
                  try
                  {
                      ISession session = null;
                      if (m_factory == null)
                      {
                          m_factory = m_cfg.Configure().Configure().AddAssembly(AssemblyClassName).BuildSessionFactory();
                          session = m_factory.OpenSession();
                      }
                      else
                      {
                          session = m_factory.OpenSession();
                      }
                      return session;
                  }
                  catch (Exception e)
                  {
                      return null;
                      throw e;
                  }
              }
  • 相关阅读:
    自定义TabBarController
    UITabBarController剖析
    IOS中UIScrollView的contentSize、contentOffset和contentInset属性
    iOS开发 剖析网易新闻标签栏视图切换
    transitionFromViewController方法的使用
    ViewController生命周期
    1816. Truncate Sentence
    1290. 二进制链表转整数
    1302. 层数最深叶子节点的和
    102.二叉树的层次遍历
  • 原文地址:https://www.cnblogs.com/Liao/p/2142787.html
Copyright © 2011-2022 走看看