• mybatis generator生成连接mysql与sqlserver的区别


    mybatis generator生成连接mysql与sqlserver所在的区别在于驱动和数据库URL不同

    mybatis generator连接mysql的配置文件是:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE generatorConfiguration
      PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
      "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
          
        <generatorConfiguration>
    	   
    	   <!--数据库驱动包位置-->
            <classPathEntry location="...mysql-connector-java-5.1.7-bin.jar" />  
          
            <context id="DB2Tables" targetRuntime="MyBatis3"> 
                <commentGenerator>  
                    <property name="suppressAllComments" value="true" />  
                </commentGenerator>  
          
    	     <!--数据库URL、用户名、密码-->
                <jdbcConnection driverClass="com.mysql.jdbc.Driver"  
                    connectionURL="jdbc:mysql://localhost/数据库" userId="登录名" password="密码">  
                </jdbcConnection>  
             
    		  
                <javaTypeResolver>  
                    <property name="forceBigDecimals" value="false" />  
                </javaTypeResolver>  
        
              <!--生成模型包的位置 -->
                <javaModelGenerator targetPackage="fl.shopping.entity"  
                    targetProject="E:	able">  
                    <property name="enableSubPackages" value="true" />  
                    <property name="trimStrings" value="true" />  
                </javaModelGenerator>  
    			
               <!--生成映射文件的包名和位置-->
                <sqlMapGenerator targetPackage="fl.shopping.mapping"  targetProject="E:	able">  
                    <property name="enableSubPackages" value="true" />  
                </sqlMapGenerator>  
           
    	        <!--生成映dao的包名和位置-->
                <javaClientGenerator type="XMLMAPPER"  
                    targetPackage="fl.shopping.dao" targetProject="E:	able">  
                    <property name="enableSubPackages" value="true" />  
                </javaClientGenerator> 
    			
                <!--需要生成那些数据库(更改tableName和domainObjectName)-->
                <table tableName="users" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" 
    			enableDeleteByExample="false"                enableSelectByExample="false" selectByExampleQueryId="false"  >  
                </table> 
    			
    			
            </context>  
        </generatorConfiguration>  
    

      

    连接sqlserver不同的在于:

    <classPathEntry location="....sqljdbc4-3.0.jar" />  
    
    <jdbcConnection driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver"  
                    connectionURL="jdbc:sqlserver://localhost:1433;DatabaseName=数据库" userId="登录名" password="密码">  
                </jdbcConnection>  
    

      

  • 相关阅读:
    Codeforces Round #260 (Div. 1) A
    cdoj 1131 男神的礼物 区间dp
    bzoj2435: [Noi2011]道路修建 树上dp
    hdu 4597 Play Game 区间dp
    cdoj 31 饭卡(card) 01背包
    hdu5256 序列变换 dp LIS
    BZOJ 4027: [HEOI2015]兔子与樱花 树上dp
    Codeforces Round #202 (Div. 1) D. Turtles dp
    hdu 4114 Disney's FastPass 状压dp
    Python help() 函数
  • 原文地址:https://www.cnblogs.com/John-Lyn/p/4166415.html
Copyright © 2020-2023  润新知