mybatis generator生成鏈接mysql與sqlserver的區別

mybatis generator生成鏈接mysql與sqlserver所在的區別在於驅動和數據庫URL不一樣java

 

mybatis generator鏈接mysql的配置文件是: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:\table">  
                <property name="enableSubPackages" value="true" />  
                <property name="trimStrings" value="true" />  
            </javaModelGenerator>  
			
           <!--生成映射文件的包名和位置-->
            <sqlMapGenerator targetPackage="fl.shopping.mapping"  targetProject="E:\table">  
                <property name="enableSubPackages" value="true" />  
            </sqlMapGenerator>  
       
	        <!--生成映dao的包名和位置-->
            <javaClientGenerator type="XMLMAPPER"  
                targetPackage="fl.shopping.dao" targetProject="E:\table">  
                <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不一樣的在於:sql

<classPathEntry location="....\sqljdbc4-3.0.jar" />  

<jdbcConnection driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver"  
                connectionURL="jdbc:sqlserver://localhost:1433;DatabaseName=數據庫" userId="登陸名" password="密碼">  
            </jdbcConnection>  
相關文章
相關標籤/搜索