Class DbMetaDataUtil


  • public class DbMetaDataUtil
    extends Object
    数据库相关操作工具类
    Author:
    dingzhaojun, qinman, mengjuhua, shidaobang, zhangchongjie
    • Constructor Detail

      • DbMetaDataUtil

        public DbMetaDataUtil()
    • Method Detail

      • batchExecuteDdl

        public static int[] batchExecuteDdl​(DataSource dataSource,
                                            List<String> sqlList)
                                     throws SQLException
        批量执行sql语句
        Parameters:
        dataSource - 数据源
        sqlList - sql语句列表
        Returns:
        int[] 执行
        Throws:
        SQLException - sql异常信息
      • batchExecuteDdl4Kingbase

        public static int[] batchExecuteDdl4Kingbase​(DataSource dataSource,
                                                     List<String> sqlList)
                                              throws SQLException
        KINGBASE批量执行SQL
        Parameters:
        dataSource - 数据源
        sqlList - sql语句列表
        Returns:
        int[] 执行
        Throws:
        SQLException - sql异常信息
      • checkTableExist

        public static boolean checkTableExist​(DataSource dataSource,
                                              String tableName)
                                       throws Exception
        验证表是否存在
        Parameters:
        dataSource - 数据源
        tableName - 表名称
        Returns:
        boolean 表是否存在
        Throws:
        Exception - 异常信息
      • executeDdl

        public static Boolean executeDdl​(DataSource dataSource,
                                         String sql)
                                  throws SQLException
        执行单条SQL语句
        Parameters:
        dataSource - 数据源
        sql - any SQL statement
        Returns:
        Boolean 判断结果
        Throws:
        SQLException - sql异常信息
      • getDatabaseDialectName

        public static String getDatabaseDialectName​(DataSource dataSource)
        获取数据库方言
        Parameters:
        dataSource - 数据源
        Returns:
        String 数据库方言
      • getDatabaseDialectNameByConnection

        public static String getDatabaseDialectNameByConnection​(Connection connection)
        获取数据库方言
        Parameters:
        connection - 数据库的连接
        Returns:
        String 数据库方言
      • listAllTablesTree

        public static String listAllTablesTree​(DataSource dataSource,
                                               String tableNamePattern)
                                        throws Exception
        获全部表的树 供应商 Catalog支持 Schema支持 Oracle 不支持 Oracle User ID MySQL 不支持 数据库名 MSSQL 数据库名 对象属主名 Sybase 数据库名 数据库属主名 Informix 不支持 不需要 PointBase 不支持 数据库名
        Parameters:
        dataSource - 数据源
        tableNamePattern - 表名
        Returns:
        String 表树JSON信息
        Throws:
        Exception - 异常