Buggy code:
public class GTFSuploader { private static Connection dbConnection ; private static String startDate ; private static String endDate ; public static final String COMMA_DELIM_DBL_QUOTE_PATTERN = ",(?=([^\"]*\"[^\"]*\")*(?![^\"]*\"))" ; public static void main ( String [ ] args ) { } private static void openDatabaseConnection ( ) throws SQLException { } private static void closeDatabaseConnection ( ) throws SQLException { } private static void openFeedInfo ( ) throws IOException { } private static void readStops ( ) throws IOException , SQLException { } private static void createStopsTable ( ) throws SQLException { } private static void readStopTimes ( ) throws IOException , SQLException { } private static void createStopsTimesTable ( ) throws SQLException { } private static void readFrequencies ( ) throws IOException , SQLException { } private static void createFrequenciesTable ( ) throws SQLException { } private static void readCalendar ( ) throws IOException , SQLException { } private static void createCalendarTable ( ) throws SQLException { } private static void readCalendar_dates ( ) throws IOException , SQLException { } private static void createCalendar_datesTable ( ) throws SQLException { } private static void readTrips ( ) throws IOException , SQLException { } private static void createTripsTable ( ) throws SQLException { } private static void readTransfers ( ) throws IOException , SQLException { } private static void createTransfersTable ( ) throws SQLException { } private static void readRoutes ( ) throws IOException , SQLException { } private static void createRoutesTable ( ) throws SQLException { } private static void insertStopGeometry ( ) throws SQLException { } private static void createStopGeometryTable ( ) throws SQLException { } private static void insertNearestStopStopMatrix ( ) throws SQLException { if ( GTFSuploader . dbConnection . isClosed ( ) ) { GTFSuploader . openDatabaseConnection ( ) ; } try { GTFSuploader . createNearestStopStopMatrixTable ( ) ; } catch ( PSQLException e ) { System . out . println ( e ) ; } <START_BUG> String insertQuery = ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( "WITH<seq2seq4repair_space>stops<seq2seq4repair_space>AS(\n" + ( "SELECT<seq2seq4repair_space>DISTINCT<seq2seq4repair_space>stops.stop_id,<seq2seq4repair_space>geog_latlon\n" + "FROM<seq2seq4repair_space>gtfs.stops_" ) ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>stops<seq2seq4repair_space>\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>gtfs.stop_times_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>stop_times<seq2seq4repair_space>ON<seq2seq4repair_space>stop_times.stop_id<seq2seq4repair_space>=<seq2seq4repair_space>stops.stop_id\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>gtfs.trips_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>trips<seq2seq4repair_space>ON<seq2seq4repair_space>trips.trip_id<seq2seq4repair_space>=<seq2seq4repair_space>stop_times.trip_id\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>gtfs.routes_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>routes<seq2seq4repair_space>ON<seq2seq4repair_space>routes.route_id<seq2seq4repair_space>=<seq2seq4repair_space>trips.route_id\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>gtfs.stops_geog_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>ON<seq2seq4repair_space>gtfs.stops_geog_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + ".stop_id<seq2seq4repair_space>=<seq2seq4repair_space>stops.stop_id\n" ) + "WHERE<seq2seq4repair_space>route_type<seq2seq4repair_space>=<seq2seq4repair_space>3\n" ) + ")\n" ) + ",<seq2seq4repair_space>nearest_matrix<seq2seq4repair_space>AS<seq2seq4repair_space>(\n" ) + "\n" ) + "SELECT<seq2seq4repair_space>stops_geog.stop_id<seq2seq4repair_space>AS<seq2seq4repair_space>next_o,<seq2seq4repair_space>\n" ) + "\t\t(SELECT<seq2seq4repair_space>nearest.stop_id<seq2seq4repair_space>FROM<seq2seq4repair_space>stops<seq2seq4repair_space>nearest<seq2seq4repair_space>WHERE<seq2seq4repair_space>nearest.stop_id<seq2seq4repair_space>!=<seq2seq4repair_space>main.stop_id\n" ) + "<seq2seq4repair_space>ORDER<seq2seq4repair_space>BY<seq2seq4repair_space>CAST(nearest.geog_latlon<seq2seq4repair_space>AS<seq2seq4repair_space>geometry)<seq2seq4repair_space><-><seq2seq4repair_space>CAST(gtfs.stops_geog_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + ".geog_latlon<seq2seq4repair_space>AS<seq2seq4repair_space>geometry)\n" ) + "\t\tLIMIT<seq2seq4repair_space>1)<seq2seq4repair_space>AS<seq2seq4repair_space>nearest_stop\n" ) + "FROM<seq2seq4repair_space>stops<seq2seq4repair_space>main\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>gtfs.stops_geog_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>stops_geog<seq2seq4repair_space>ON<seq2seq4repair_space>stops_geog.stop_id<seq2seq4repair_space>=<seq2seq4repair_space>main.stop_id\n" ) + ")\n" ) + "\n" ) + "INSERT<seq2seq4repair_space>INTO<seq2seq4repair_space>gtfs.stop_stop_matrix_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "\n" ) + "(SELECT<seq2seq4repair_space>next_o,<seq2seq4repair_space>nearest_stop,<seq2seq4repair_space>CAST(ST_DISTANCE(stops.geog_latlon,<seq2seq4repair_space>o.geog_latlon)<seq2seq4repair_space>AS<seq2seq4repair_space>INT)as<seq2seq4repair_space>nearest_distance\n" ) + "FROM<seq2seq4repair_space>nearest_matrix\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>stops<seq2seq4repair_space>ON<seq2seq4repair_space>stops.stop_id<seq2seq4repair_space>=<seq2seq4repair_space>nearest_matrix.next_o\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>gtfs.stops_geog_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>o<seq2seq4repair_space>ON<seq2seq4repair_space>o.stop_id<seq2seq4repair_space>=<seq2seq4repair_space>next_o);" ; <END_BUG> try { PreparedStatement insert = GTFSuploader . dbConnection . prepareStatement ( insertQuery ) ; insert . execute ( ) ; } catch ( PSQLException ex ) { System . out . println ( ex ) ; System . out . println ( ex . getServerErrorMessage ( ) . getMessage ( ) ) ; } } private static void createNearestStopStopMatrixTable ( ) throws SQLException { } private static void insertBusPatterns ( ) throws SQLException { } private static void createBus_patterns_Table ( ) throws SQLException { } private static void basicKeys ( ) throws SQLException { } private static void advancedKeys ( ) throws SQLException { } }

Fix:
String insertQuery = ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( "WITH<seq2seq4repair_space>stops<seq2seq4repair_space>AS(\n" + ( "SELECT<seq2seq4repair_space>DISTINCT<seq2seq4repair_space>stops.stop_id,<seq2seq4repair_space>geog_latlon\n" + "FROM<seq2seq4repair_space>gtfs.stops_" ) ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>stops<seq2seq4repair_space>\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>gtfs.stop_times_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>stop_times<seq2seq4repair_space>ON<seq2seq4repair_space>stop_times.stop_id<seq2seq4repair_space>=<seq2seq4repair_space>stops.stop_id\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>gtfs.trips_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>trips<seq2seq4repair_space>ON<seq2seq4repair_space>trips.trip_id<seq2seq4repair_space>=<seq2seq4repair_space>stop_times.trip_id\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>gtfs.routes_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>routes<seq2seq4repair_space>ON<seq2seq4repair_space>routes.route_id<seq2seq4repair_space>=<seq2seq4repair_space>trips.route_id\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>gtfs.stops_geog_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>ON<seq2seq4repair_space>gtfs.stops_geog_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + ".stop_id<seq2seq4repair_space>=<seq2seq4repair_space>stops.stop_id\n" ) + "WHERE<seq2seq4repair_space>route_type<seq2seq4repair_space>=<seq2seq4repair_space>3\n" ) + ")\n" ) + ",<seq2seq4repair_space>nearest_matrix<seq2seq4repair_space>AS<seq2seq4repair_space>(\n" ) + "\n" ) + "SELECT<seq2seq4repair_space>stops_geog.stop_id<seq2seq4repair_space>AS<seq2seq4repair_space>next_o,<seq2seq4repair_space>\n" ) + "\t\t(SELECT<seq2seq4repair_space>nearest.stop_id<seq2seq4repair_space>FROM<seq2seq4repair_space>stops<seq2seq4repair_space>nearest<seq2seq4repair_space>WHERE<seq2seq4repair_space>nearest.stop_id<seq2seq4repair_space>!=<seq2seq4repair_space>main.stop_id\n" ) + "\t\t\tORDER<seq2seq4repair_space>BY<seq2seq4repair_space>CAST(nearest.geog_latlon<seq2seq4repair_space>AS<seq2seq4repair_space>geometry)<seq2seq4repair_space><-><seq2seq4repair_space>CAST(stops_geog.geog_latlon<seq2seq4repair_space>AS<seq2seq4repair_space>geometry)\n" ) + "\t\tLIMIT<seq2seq4repair_space>1)<seq2seq4repair_space>AS<seq2seq4repair_space>nearest_stop\n" ) + "FROM<seq2seq4repair_space>stops<seq2seq4repair_space>main\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>gtfs.stops_geog_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>stops_geog<seq2seq4repair_space>ON<seq2seq4repair_space>stops_geog.stop_id<seq2seq4repair_space>=<seq2seq4repair_space>main.stop_id\n" ) + ")\n" ) + "\n" ) + "INSERT<seq2seq4repair_space>INTO<seq2seq4repair_space>gtfs.stop_stop_matrix_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "\n" ) + "(SELECT<seq2seq4repair_space>next_o,<seq2seq4repair_space>nearest_stop,<seq2seq4repair_space>CAST(ST_DISTANCE(stops.geog_latlon,<seq2seq4repair_space>o.geog_latlon)<seq2seq4repair_space>AS<seq2seq4repair_space>INT)as<seq2seq4repair_space>nearest_distance\n" ) + "FROM<seq2seq4repair_space>nearest_matrix\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>stops<seq2seq4repair_space>ON<seq2seq4repair_space>stops.stop_id<seq2seq4repair_space>=<seq2seq4repair_space>nearest_matrix.next_o\n" ) + "INNER<seq2seq4repair_space>JOIN<seq2seq4repair_space>gtfs.stops_geog_" ) + ( GTFSuploader . startDate ) ) + "_" ) + ( GTFSuploader . endDate ) ) + "<seq2seq4repair_space>o<seq2seq4repair_space>ON<seq2seq4repair_space>o.stop_id<seq2seq4repair_space>=<seq2seq4repair_space>next_o);" ;