@Component
public class CheckDataBase {
@Autowired
private ZhutiMapper zhutiMapper;
private static CheckDataBase checkDataBase;
@PostConstruct
public void init() {
checkDataBase = this;
checkDataBase.zhutiMapper = this.zhutiMapper;
}
public static boolean get(String name) {
String flag = checkDataBase.zhutiMapper.CheckDataBase(name);
if ("t".equals(flag)) {
return true;
}
return false;
}
}
@Component
public class CheckDataBase {
private static ZhutiMapper zhutiMapper;
@Autowired
public CheckDataBase(ZhutiMapper zhutiMapper) {
CheckDataBase.zhutiMapper = zhutiMapper;
}
public static boolean get(String name) {
String flag = zhutiMapper.CheckDataBase(name);
if ("t".equals(flag)) {
return true;
}
return false;
}
}
用这种方式,同时附上postgresql检测表的方法:
<select id="CheckDataBase" resultType="String">
SELECT to_regclass("${name}") is not null
</select>
返回t是true,f是false