Skip to content

Commit

Permalink
Fix #72 selection of Cities like in Damascus, Syria
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanBayoumi committed Oct 5, 2024
1 parent ce85e5c commit a7b0ffa
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Azkar/src/main/java/com/bayoumi/models/location/City.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ PRIMARY KEY("locId")
)
* */
public static ArrayList<City> getCitiesInCountry(String code) {
ArrayList<City> cities = new ArrayList<>();
final ArrayList<City> cities = new ArrayList<>();
try {
ResultSet res = LocationsDBManager.getInstance().con.prepareStatement("SELECT * from (SELECT * from (SELECT * from cityd WHERE country='" + code + "' GROUP BY city) " +
"WHERE country='" + code + "' GROUP BY longitude) " +
"WHERE country='" + code + "' GROUP BY latitude ORDER BY city ASC;").executeQuery();
final ResultSet res = LocationsDBManager.getInstance().con.prepareStatement("SELECT * from cityd WHERE country='" + code + "' GROUP BY city;").executeQuery();
while (res.next()) {
cities.add(new City(
res.getString("country"), res.getString("city"),
Expand All @@ -71,10 +69,10 @@ public static ArrayList<City> getCitiesInCountry(String code) {

public static City getCityFromEngName(String englishName, String countryCode) {
try {
PreparedStatement statement = LocationsDBManager.getInstance().con.prepareStatement("SELECT * FROM cityd WHERE city = ? AND country = ?");
final PreparedStatement statement = LocationsDBManager.getInstance().con.prepareStatement("SELECT * FROM cityd WHERE city = ? AND country = ?");
statement.setString(1, englishName);
statement.setString(2, countryCode);
ResultSet res = statement.executeQuery();
final ResultSet res = statement.executeQuery();
if (res.next()) {
return new City(
res.getString("country"), res.getString("city"),
Expand Down

0 comments on commit a7b0ffa

Please sign in to comment.