测试
string
sqlserver
url
oracle
数据库
[java]
view plain
copy
- ?
- ?
- ?
- ?
- ?
- ??
- ????private?boolean?testHost(Map<String,?String>?props)?{??
- ????????boolean?status?=?false;??
- ??????????
- ????????int?timeout?=?3000;??
- ????????String?url?=?props.get("url");??
- ????????String?dbtype?=?(String)?Globals.SYS_DB_TYPE.get(props.get("name"));??
- ????????String?host?=?"";??
- ??????????
- ??????????
- ????????if?("1".equals(dbtype))?{??
- ????????????if(url?!=?null?&&?!"".equals(url)?&&?url.indexOf("@")?>?0)??
- ????????????host?=?url.substring(url.indexOf("@")?+?1,?url.indexOf(":",?url.indexOf("@")));??
- ????????}?else?{???
- ????????????if(url?!=?null?&&?!"".equals(url)?&&?url.indexOf("//")?>?0)??
- ????????????host?=?url.substring(url.indexOf("//")?+?2,?url.indexOf("//")));??
- ????????}??
- ??
- ????????try?{??
- ????????????if?(InetAddress.getByName(host).isReachable(timeout))?{??
- ????????????????logger.info("IP:?"?+?host?+?"?正常连接");??
- ????????????????status?=?true;??
- ????????????}?else?{??
- ????????????????logger.info("IP:?"?+?host?+?"?无法连接");??
- ????????????????status?=?false;??
- ????????????}??
- ????????}?catch?(UnknownHostException?e)?{??
- ????????????logger.info(host?+?"是非法的地址");??
- ????????????e.printStackTrace();??
- ????????}?catch?(IOException?e)?{??
- ????????????e.printStackTrace();??
- ????????}?
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|