MyBatis Generator Build Connection The difference between MySQL and SQL Server is that the driver and the database URL are different
MyBatis Generator The configuration file that connects MySQL is:
<?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> <!--Database Driver package Location-- <classpathentry location= "... \mysql-connector-java-5.1.7-bin.jar"/> <context id= "DB2Tables" Targetruntime= "MyBatis3" > <commentGenerator> <property name= "suppressallcomments "Value=" true "/> </commentGenerator> <!--database URL, username, password--<jdbcconn Ection driverclass= "Com.mysql.jdbc.Driver" connectionurl= "jdbc:mysql://localhost/database" userid= "Login name" Passwo rd= "Password" > </jdbcConnection> <javaTypeResolver> <pro Perty name= "Forcebigdecimals" value= "false"/> </javaTypeResolver> <!--Generate the Model package location--<javamodelgenerator targetpackage= "fl.shopping.entity" targetproject= "e:\ Table "> <property name=" enablesubpackages "value=" true "/> <property name=" t Rimstrings "value=" true "/> </javaModelGenerator> <!--build the package name and location of the mapping file----& Lt;sqlmapgenerator targetpackage= "fl.shopping.mapping" targetproject= "E:\table" > <property name= "E Nablesubpackages "value=" true "/> </sqlMapGenerator> <!--generate the package name and location of the map DAO-- <javaclientgenerator type= "Xmlmapper" targetpackage= "Fl.shopping.dao" targetproject= "E:\table" &G T <property name= "Enablesubpackages" value= "true"/> </javaClientGenerator> <!--needs to be generated Those databases (change TableName and Domainobjectname)-<table tablename= "users" Domainobjectname= "User" Enablecountbyexam ple="False" enableupdatebyexample= "false" enabledeletebyexample= "false" enableselectbyexample= "false" Selectbye Xamplequeryid= "false" > </table> </context> </generatorConfiguration>
The difference between connecting to SQL Server is:
<classpathentry location= ".... \sqljdbc4-3.0.jar"/> <jdbcconnection driverclass= " Com.microsoft.sqlserver.jdbc.SQLServerDriver " connectionurl=" jdbc:sqlserver://localhost:1433;databasename= Database "userid=" login name "password=" Password > </jdbcConnection>
MyBatis Generator generation connection mysql differs from SQL Server