import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class InterfaceTest
{
public static void main(String[] args) throws Exception
{
//需导入Oracle驱动
Class.forName("oracle.jdbc.OracleDriver");
Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@10.18.20.180:1521:MUDATA",
"MD_REF",
"MD_REF_2018");
PreparedStatement statement = conn.prepareStatement("SELECT IATA_CD FROM T13_REF_AIRPORT_HUB");
ResultSet resultSet = statement.executeQuery();
List data_list = new ArrayList<>();
while (resultSet.next())
{
data_list.add("http://10.18.20.5:8082/mudata/api/v1/timechange/gettimezone/11/?changeType=3&airportCode=" + resultSet.getString(1) + "&dateTime=2019-09-11%2009:00:00");
// data_list.add("http://localhost:8080");//4s
}
String start_time=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS").format(new Date());
// int i=0;
for (String data : data_list)
{
// System.out.println(++i);
new URL(data).openConnection().getInputStream();//调用一次
}
System.out.println(start_time);
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS").format(new Date()));
statement.close();
conn.close();
//2019-10-12 11:12:49 844 2019-10-12 11:14:44 365
//2019-10-12 11:19:42 559 2019-10-12 11:21:39 207
// String x="http://10.18.20.5:8082/mudata/api/v1/timechange/gettimezone/11/?changeType=3&airportCode=PVG&dateTime=2019-09-11%2009:00:00";
// HttpURLConnection http = (HttpURLConnection) new URL(x).openConnection();
// http.setRequestMethod("GET");
// URL u=new URL("http://10.68.169.204:8080/");
//获取连接对象
// HttpURLConnection conn=(HttpURLConnection) u.openConnection();
// //连接
// conn.connect();
// //获取输入流
// InputStream in=conn.getInputStream();
// //读取输入流
// int r;
// byte[] bs=new byte[1024];
// StringBuffer sb=new StringBuffer();
// while((r=in.read(bs))!=-1) {
// sb.append(new String(bs, 0, r));
// }
// in.close();
// System.out.println(sb.toString());
// new URL("http://localhost:8080").openConnection().getInputStream();
}
}