cn.schoolwow.quickdao.module.initial.flow.database.SetQueryDatabaseStatementFlow Maven / Gradle / Ivy
package cn.schoolwow.quickdao.module.initial.flow.database;
import cn.schoolwow.quickdao.domain.database.parent.DatabaseType;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
public class SetQueryDatabaseStatementFlow implements BusinessFlow {
@Override
public void executeBusinessFlow(FlowContext flowContext) throws Exception {
DatabaseType databaseType = (DatabaseType) flowContext.checkData("databaseType");
String queryDatabaseSQL = null;
switch (databaseType){
case H2:{queryDatabaseSQL = "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA;";}break;
case MariaDB:
case Mysql:{queryDatabaseSQL = "SHOW DATABASES;";}break;
case Postgresql:{queryDatabaseSQL = "SELECT datname FROM pg_database;";}break;
case SQLServer:{queryDatabaseSQL = "SELECT name FROM sys.databases;";}break;
case Oracle:{queryDatabaseSQL = "SELECT table_name FROM user_tables;";}break;
default:{
flowContext.broken("不支持的数据库类型!"+databaseType.name());
}break;
}
flowContext.putTemporaryData("queryDatabaseSQL", queryDatabaseSQL);
}
@Override
public String name() {
return "设置查询数据库是否存在语句";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy