Speed up multiple JDBC SQL querys?
- by paddydub
I'm working on a shortest path a* algorithm in java with a mysql db. I'm executing the following SQL Query approx 300 times in the program to find route connections from a database of 10,000 bus connections. It takes approx 6-7 seconds to execute the query 300 times. Any suggestions on how I can speed this up or any ideas on a different method i can use ? Thanks
ResultSet rs = stmt.executeQuery("select * from connections" +
" where Connections.From_Station_stopID ="+StopID+";");
while (rs.next()) {
int id = rs.getInt("To_Station_id");
String routeID = rs.getString("To_Station_routeID");
Double lat = rs.getDouble("To_Station_lat");
Double lng = rs.getDouble("To_Station_lng");
int time = rs.getInt("Time");
}