private static Connection conn=null;
private static PreparedStatement ps=null;
private static CallableStatement cs=null;
private static ResultSet rs=null;
public static void openConnection(){
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String dbURL = "jdbc:sqlserver://localhost:1433;DatabaseName=json";
String userName = "root";
String userPwd = "123";
try{
Class.forName(driverName);
conn = DriverManager.getConnection(dbURL, userName,userPwd);
System.out.println("连接数据库成功");
}
catch (Exception e){
e.printStackTrace();
System.out.print("连接失败");
}
}
- - - - - - - 数据库连接已经写好, 求(气象局接口获取天气预报json数据,解析并存入数据库)代码