diff --git a/CHANGELOG.md b/CHANGELOG.md
index c8b525513..b21ded5a9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@
* 【core 】 使多个xxxBuilder实现Builder接口,扩展CheckedUtil(pr#545@Gitee)
* 【core 】 CheckedUtil删除第二个参数为RuntimeException的方法
* 【core 】 FileUtil增加getTotalLines方法
+* 【db 】 MetaUtil增加getTableMeta重载(issue#2157@Github)
### 🐞Bug修复
* 【cache 】 修复ReentrantCache.toString方法线程不安全问题(issue#2140@Github)
diff --git a/hutool-core/src/test/java/cn/hutool/core/date/ChineseDateTest.java b/hutool-core/src/test/java/cn/hutool/core/date/ChineseDateTest.java
index e2d86d1e9..d75f01f59 100644
--- a/hutool-core/src/test/java/cn/hutool/core/date/ChineseDateTest.java
+++ b/hutool-core/src/test/java/cn/hutool/core/date/ChineseDateTest.java
@@ -1,9 +1,12 @@
package cn.hutool.core.date;
+import cn.hutool.core.lang.Console;
import cn.hutool.core.util.StrUtil;
import org.junit.Assert;
import org.junit.Test;
+import java.util.Date;
+
public class ChineseDateTest {
@Test
@@ -113,4 +116,12 @@ public class ChineseDateTest {
final String chineseMonth = springFestival.getChineseMonth();
Assert.assertEquals("一月", chineseMonth);
}
+
+ @Test
+ public void dayTest(){
+ Date date = DateUtil.parse("1900-01-31");
+ //Date date = DateUtil.parse("2022-02-22","yyyy-MM-dd");
+ ChineseDate chineseDate = new ChineseDate(date);
+ Console.log(chineseDate);
+ }
}
diff --git a/hutool-db/src/main/java/cn/hutool/db/meta/MetaUtil.java b/hutool-db/src/main/java/cn/hutool/db/meta/MetaUtil.java
index 04854a10e..caea07f65 100644
--- a/hutool-db/src/main/java/cn/hutool/db/meta/MetaUtil.java
+++ b/hutool-db/src/main/java/cn/hutool/db/meta/MetaUtil.java
@@ -185,15 +185,38 @@ public class MetaUtil {
* @return Table对象
*/
public static Table getTableMeta(DataSource ds, String tableName) {
+ return getTableMeta(ds, null, null, tableName);
+ }
+
+ /**
+ * 获得表的元信息
+ * 注意如果需要获取注释,某些数据库如MySQL,需要在配置中添加:
+ *
+ * remarks = true + * useInformationSchema = true + *+ * + * @param ds 数据源 + * @param tableName 表名 + * @param catalog catalog name,{@code null}表示自动获取,见:{@link #getCataLog(Connection)} + * @param schema a schema name pattern,{@code null}表示自动获取,见:{@link #getSchema(Connection)} + * @return Table对象 + * @since 5.7.22 + */ + public static Table getTableMeta(DataSource ds, String catalog, String schema, String tableName) { final Table table = Table.create(tableName); Connection conn = null; try { conn = ds.getConnection(); // catalog和schema获取失败默认使用null代替 - final String catalog = getCataLog(conn); + if(null == catalog){ + catalog = getCataLog(conn); + } table.setCatalog(catalog); - final String schema = getSchema(conn); + if(null == schema){ + schema = getSchema(conn); + } table.setSchema(schema); final DatabaseMetaData metaData = conn.getMetaData();