Java - JDBC - callResultSetProc
public void callResultSetProc () throws SQLException {
try (
Connection conn = DriverManager.getConnection(url, username, password);
CallableStatement callst = conn.prepareCall("{call showCitiesInCountry(?)}")
)
{
System.out.print("Enter Country Name: ");
callst.setString(1, scanner.nextLine());
ResultSet rs = callst.executeQuery();
String format = "%-10s%-10s%-10s%-10s%-10s\n";
while (rs.next()) {
System.out.format(format, rs.getString("ID"), rs.getString("Name"), rs.getString("CountryCode"),
rs.getString("District"), rs.getInt("Population"));
}
}
catch (SQLException e){
System.out.println("Error: " + e);
}
}