• 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>  
    

      

  • 相关阅读:
    Android之旅十六 android中各种资源的使用
    XTU OJ 1207 Welcome to XTCPC (字符串签到题)
    scala并发编程原生线程Actor、Case Class下的消息传递和偏函数实战
    【云图】怎样设置支付宝里的家乐福全国连锁店地图?
    怎样在QML中使用multitouch
    软件project师周兆熊给IT学子的倾情奉献
    Linux系统下怎样配置SSH?怎样开启SSH?
    数学之路-python计算实战(4)-Lempel-Ziv压缩(2)
    Day5上午解题报告
    一份只有巨佬才能看懂的代码
  • 原文地址:https://www.cnblogs.com/John-Lyn/p/4166415.html
Copyright © 2020-2023  润新知