测试IP是否连通的方法1

/**
	 * 测试IP是否连通 Author zyx Date 2012-04-18
	 * 
	 * @param host
	 * @return
	 */
	private boolean testHost(Map<String,String> props) {
		boolean status = false;
		// 设置验证IP连通延迟时间
		int timeout = 3000;
		String url = props.get("url");
		String dbtype = (String) Globals.SYS_DB_TYPE.get(props.get("name"));
		String host = "";
		// 从url中截取IP连接地址 这里的截取方法支持oracle sqlserver MysqL DB2 不支持sybase
		// 如果是oracle数据库
		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();
		}

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 &#39;EastRiver&#39; 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...