Package net.risesoft.y9.sqlddl
Class DbMetaDataUtil
- java.lang.Object
-
- net.risesoft.y9.sqlddl.DbMetaDataUtil
-
public class DbMetaDataUtil extends Object
数据库相关操作工具类- Author:
- dingzhaojun, qinman, mengjuhua, shidaobang, zhangchongjie
-
-
Constructor Summary
Constructors Constructor Description DbMetaDataUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int[]batchExecuteDdl(DataSource dataSource, List<String> sqlList)批量执行sql语句static int[]batchExecuteDdl4Kingbase(DataSource dataSource, List<String> sqlList)KINGBASE批量执行SQLstatic booleancheckTableExist(DataSource dataSource, String tableName)验证表是否存在static BooleanexecuteDdl(DataSource dataSource, String sql)执行单条SQL语句static StringgetDatabaseDialectName(DataSource dataSource)获取数据库方言static StringgetDatabaseDialectNameByConnection(Connection connection)获取数据库方言static intgetDatabaseMajorVersion(DataSource dataSource)static intgetDatabaseMinorVersion(DataSource dataSource)static StringgetDatabaseProductName(DataSource dataSource)static StringgetDatabaseProductNameByConnection(Connection connection)static StringgetDatabaseProductVersion(DataSource dataSource)static List<DbColumn>listAllColumns(DataSource dataSource, String tableName, String columnNamePatten)static List<org.apache.commons.beanutils.DynaBean>listAllExportedKeys(DataSource dataSource, String tableName)static List<org.apache.commons.beanutils.DynaBean>listAllImportedKeys(DataSource dataSource, String tableName)static List<org.apache.commons.beanutils.DynaBean>listAllIndexs(DataSource dataSource, String tableName)static List<org.apache.commons.beanutils.DynaBean>listAllRelations(DataSource dataSource, String tableName)static List<Map<String,String>>listAllTables(DataSource dataSource, String tableNamePattern)static List<org.apache.commons.beanutils.DynaBean>listAllTables(DataSource dataSource, String catalog, String schemaPattern, String tableNamePattern, String[] types)static StringlistAllTablesTree(DataSource dataSource, String tableNamePattern)获全部表的树 供应商 Catalog支持 Schema支持 Oracle 不支持 Oracle User ID MySQL 不支持 数据库名 MSSQL 数据库名 对象属主名 Sybase 数据库名 数据库属主名 Informix 不支持 不需要 PointBase 不支持 数据库名static List<Map<String,Object>>listAllTypes(DataSource dataSource)
-
-
-
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 数据库方言
-
getDatabaseMajorVersion
public static int getDatabaseMajorVersion(DataSource dataSource) throws SQLException
- Throws:
SQLException
-
getDatabaseMinorVersion
public static int getDatabaseMinorVersion(DataSource dataSource) throws SQLException
- Throws:
SQLException
-
getDatabaseProductName
public static String getDatabaseProductName(DataSource dataSource) throws SQLException
- Throws:
SQLException
-
getDatabaseProductNameByConnection
public static String getDatabaseProductNameByConnection(Connection connection) throws SQLException
- Throws:
SQLException
-
getDatabaseProductVersion
public static String getDatabaseProductVersion(DataSource dataSource) throws SQLException
- Throws:
SQLException
-
listAllColumns
public static List<DbColumn> listAllColumns(DataSource dataSource, String tableName, String columnNamePatten) throws Exception
- Throws:
Exception
-
listAllExportedKeys
public static List<org.apache.commons.beanutils.DynaBean> listAllExportedKeys(DataSource dataSource, String tableName) throws Exception
- Throws:
Exception
-
listAllImportedKeys
public static List<org.apache.commons.beanutils.DynaBean> listAllImportedKeys(DataSource dataSource, String tableName) throws Exception
- Throws:
Exception
-
listAllIndexs
public static List<org.apache.commons.beanutils.DynaBean> listAllIndexs(DataSource dataSource, String tableName) throws Exception
- Throws:
Exception
-
listAllRelations
public static List<org.apache.commons.beanutils.DynaBean> listAllRelations(DataSource dataSource, String tableName) throws Exception
- Throws:
Exception
-
listAllTables
public static List<Map<String,String>> listAllTables(DataSource dataSource, String tableNamePattern) throws Exception
- Throws:
Exception
-
listAllTables
public static List<org.apache.commons.beanutils.DynaBean> listAllTables(DataSource dataSource, String catalog, String schemaPattern, String tableNamePattern, String[] types) throws Exception
- Throws:
Exception
-
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- 异常
-
-