6.2 判断表是否存在

/**
 * 判断指定的表是否存在
 *
 * @param tableName
 * @return
 * @throws IOException
 */
private static boolean isTableExists(String tableName) throws IOException {
    // 创建一个连接对象
    Connection conn = ConnectionFactory.createConnection(conf);
    // 通过链接对象获取一个 Admin 对象
    Admin admin = conn.getAdmin();
    boolean isExists = admin.tableExists(TableName.valueOf(tableName));
    admin.close();
    conn.close();
    return isExists;
}
Copyright © 尚硅谷大数据 2019 all right reserved,powered by Gitbook
该文件最后修订时间: 2018-11-20 18:14:19

results matching ""

    No results matching ""