首页 > 代码库 > mybatis generator生成连接mysql与sqlserver的区别

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="http://www.mamicode.com/true" />              </commentGenerator>        	     <!--数据库URL、用户名、密码-->            <jdbcConnection driverClass="com.mysql.jdbc.Driver"                  connectionURL="jdbc:mysql://localhost/数据库" userId="登录名" password="密码">              </jdbcConnection>           		              <javaTypeResolver>                  <property name="forceBigDecimals" value="http://www.mamicode.com/false" />              </javaTypeResolver>                <!--生成模型包的位置 -->            <javaModelGenerator targetPackage="fl.shopping.entity"                  targetProject="E:\table">                  <property name="enableSubPackages" value="http://www.mamicode.com/true" />                  <property name="trimStrings" value="http://www.mamicode.com/true" />              </javaModelGenerator>  			           <!--生成映射文件的包名和位置-->            <sqlMapGenerator targetPackage="fl.shopping.mapping"  targetProject="E:\table">                  <property name="enableSubPackages" value="http://www.mamicode.com/true" />              </sqlMapGenerator>         	        <!--生成映dao的包名和位置-->            <javaClientGenerator type="XMLMAPPER"                  targetPackage="fl.shopping.dao" targetProject="E:\table">                  <property name="enableSubPackages" value="http://www.mamicode.com/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>  

  

 

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