mysql下载add producemybatisgenerator⽣成其他库同名表
记⼀次问题:mybatis generator ⽣成了其他库同名表。
解决1:
<jdbcConnection driverClass="sql.jdbc.Driver"
connectionURL="jdbc:mysql://xxxxxx/a“
userId="root"
password="xxxxxx">
<!--防⽌⽣成其他库同名表-->
<property name="nullCatalogMeansCurrent" value="true"/>
</jdbcConnection>
解决2:
<jdbcConnection driverClass="sql.jdbc.Driver"
connectionURL="jdbc:mysql://xxxxxx/a?nullCatalogMeansCurrent=true“
userId="root"
password="xxxxxx">
</jdbcConnection>
官⽅解释:
MySql不能正确⽀持SQL catalogs和schema。如果 在MySql中运⾏create schema命令,它实际上会创建⼀个数据库 - 并且JDBC驱动程序将其作为catalogs报告回来。但是MySql语法不⽀持标准的catalog…table SQL语法。
因此,最好不要在generator 配置中指定catalog或schema。只需指定表名并在JDBC URL中指定数据库即可。
如果您使⽤的是mysql-connector-java的8.x版,⽣成器可能会尝试为MySql information schemas中的表⽣成代码。要禁⽤此⾏为,请将属性“nullCatalogMeansCurrent = true”添加到JDBC URL。
MySql does not properly support SQL catalogs and schema. If you run the create schema command in MySql, it actually creates a database - and the JDBC driver reports it back as a catalog. But MySql syntax does not support the standard catalog…table SQL syntax.
For this reason, it is best to not specify either catalog or schema in generator configurations. Just specify table names and specify the database in the JDBC URL.
If you are using version 8.x of Connector/J you may notice that the generator attempts to generate code for tables in the MySql information schemas (sys, information_schema, performance_schema, etc.) This is probably not what you want! To disable this behavior, add the property “nullCatalogMeansCurrent=true” to your JDBC URL.
扩展:
nullCatalogMeansCurrent 解释:
当DatabaseMetadataMethods请求“catalogs ”参数,值为“Null”时是否意味着使⽤当前catalogs。( 它不兼容JDBC,但符合驱动程序早期版本的传统⾏为。)
名称解释:
information schemas
information schemas数据库提供mysql数据字典查询接⼝。提供了数据库元数据的访问⽅式,记录了⼤部分我们需要了解的信息。
The name of the database that provides a query interface to the MySQL data dictionary. (This name is defined by the ANSI SQL standard.) To examine information (metadata) about the database, you can query tables such as
INFORMATION_SCHEMA.TABLES and INFORMATION_SCHEMA.COLUMNS, rather than using SHOW commands that produce unstructured output.
schema
在MySQL中,物理上,schema与database是同义词。在MySQL SQL语法中,可以⽤关键字schema替换database,例如使⽤CREATE SCHEMA⽽不是 CREATE DATABASE。
In MySQL, physically, a schema is synonymous with a database. You can substitute the keyword SCHEMA instead of DATABASE in MySQL SQL syntax, for example using CREATE SCHEMA instead of CREATE DATABASE.
catalogs
在mysql官⽹,没看到相关的解释。Stack Overflow有个回答说mysql中,database == schema == catalog ==服务器中的命名空间。但其他⽹站也有⼈说,database == schema, catalog 等于database的集合。 这个如果有知道,望告知。
参考资料
[1]解决⽅案:
[2] schema解释:
[3] information schema解释:
[4]Stack Overflow的回答:
[5]其他关于catalog的解释:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。