Пример #1
0
 /**
  * 判断数据库表是否存在(只适用于DB2)
  *
  * @param schema
  * @param tableName
  * @return true:存在;false:不存在
  * @author LiuKun
  * @throws SQLException
  * @created 2012-8-9 下午7:29:24
  */
 @Transactional
 public Boolean existTableForDB2(String schema, String tableName) {
   if (Validator.isEmpty(schema)) {
     throw new RuntimeException("schema为空!");
   }
   if (Validator.isEmpty(tableName)) {
     throw new RuntimeException("tableName为空!");
   }
   String sql = " SELECT NAME FROM SYSIBM.SYSTABLES WHERE CREATOR = ? AND NAME = ?  ";
   List<Map<String, Object>> mapList =
       executeQuery(sql, null, schema.toUpperCase(), tableName.toUpperCase());
   if (Validator.isNotEmpty(mapList)) {
     return Boolean.TRUE;
   } else {
     return Boolean.FALSE;
   }
 }
Пример #2
0
 /**
  * 检测某个属性值是否存在
  *
  * @param clazz
  * @param propertyName
  * @param value
  * @return
  * @author LiuKun
  * @created 2012-7-28 上午11:36:02
  */
 @Transactional
 public <E extends Entity> Boolean checkExist(Class<E> clazz, String propertyName, Object value) {
   List<E> list = findByProperty(clazz, propertyName, value);
   if (Validator.isEmpty(list)) {
     return Boolean.FALSE;
   } else {
     return Boolean.TRUE;
   }
 }
Пример #3
0
 /**
  * 判断数据库表是否存在
  *
  * @param tableName
  * @return true:存在;false:不存在
  * @author LiuKun
  * @throws SQLException
  * @created 2012-8-9 下午7:29:24
  */
 @Transactional
 public Boolean existTable(String tableName) {
   if (Validator.isEmpty(tableName)) {
     throw new RuntimeException("数据库表名为空!");
   }
   Boolean flag = Boolean.FALSE;
   try {
     flag = getBaseDao().existTable(tableName);
   } catch (SQLException e) {
     throw new RuntimeException(e);
   }
   return flag;
 }