Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed May 6, 2019
1 parent 0a63886 commit a8cbf1b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public class SyncFinisher {
* 构造
*
* @param threadSize 线程数
* @return this
*/
public SyncFinisher(int threadSize) {
this.beginLatch = new CountDownLatch(1);
Expand Down
30 changes: 21 additions & 9 deletions hutool-db/src/main/java/cn/hutool/db/meta/MetaUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static String[] getColumnNames(DataSource ds, String tableName) {
DbUtil.close(rs, conn);
}
}

/**
* 创建带有字段限制的Entity对象<br>
* 此方法读取数据库中对应表的字段列表,加入到Entity中,当Entity被设置内容时,会忽略对应表字段外的所有KEY
Expand All @@ -153,7 +153,7 @@ public static Entity createLimitedEntity(DataSource ds, String tableName) {
final String[] columnNames = getColumnNames(ds, tableName);
return Entity.create(tableName).setFieldNames(columnNames);
}

/**
* 获得表的元信息
*
Expand All @@ -168,17 +168,29 @@ public static Table getTableMeta(DataSource ds, String tableName) {
ResultSet rs = null;
try {
conn = ds.getConnection();
final String catalog = conn.getCatalog();
final String schema = conn.getSchema();


// catalog和schema获取失败默认使用null代替
String catalog = null;
try {
catalog = conn.getCatalog();
} catch (SQLException e) {
// ignore
}
String schema = null;
try {
schema = conn.getSchema();
} catch (SQLException e) {
// ignore
}

final DatabaseMetaData metaData = conn.getMetaData();

// 获得表元数据(表注释)
rs = metaData.getTables(catalog, schema, tableName, new String[] {TableType.TABLE.value()});
if(rs.next()) {
rs = metaData.getTables(catalog, schema, tableName, new String[] { TableType.TABLE.value() });
if (rs.next()) {
table.setComment(rs.getString("REMARKS"));
}

// 获得主键
rs = metaData.getPrimaryKeys(catalog, schema, tableName);
while (rs.next()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private boolean locationAwareLog(String fqcn, int level_int, Throwable t, String
* 获取Slf4j Logger对象
*
* @param clazz 打印日志所在类,当为{@code null}时使用“null”表示
* @return
* @return {@link Logger}
*/
private static Logger getSlf4jLogger(Class<?> clazz) {
return (null == clazz) ? LoggerFactory.getLogger(StrUtil.EMPTY) : LoggerFactory.getLogger(clazz);
Expand Down

0 comments on commit a8cbf1b

Please sign in to comment.