public List < ServerRedirect > tableServers ( int profileId , int serverGroupId ) { ArrayList < ServerRedirect > servers = new ArrayList <> ( ) ; PreparedStatement queryStatement = null ; ResultSet results = null ; try ( Connection sqlConnection = sqlService . getConnection ( ) ) { queryStatement = sqlConnection . prepareStatement ( "SELECT * FROM " + Constants . DB_TABLE_SERVERS + " WHERE " + Constants . GENERIC_PROFILE_ID + " = ?" + " AND " + Constants . SERVER_REDIRECT_GROUP_ID + " = ?" ) ; queryStatement . setInt ( 1 , profileId ) ; queryStatement . setInt ( 2 , serverGroupId ) ; results = queryStatement . executeQuery ( ) ; while ( results . next ( ) ) { ServerRedirect curServer = new ServerRedirect ( results . getInt ( Constants . GENERIC_ID ) , results . getString ( Constants . SERVER_REDIRECT_REGION ) , results . getString ( Constants . SERVER_REDIRECT_SRC_URL ) , results . getString ( Constants . SERVER_REDIRECT_DEST_URL ) , results . getString ( Constants . SERVER_REDIRECT_HOST_HEADER ) ) ; curServer . setProfileId ( profileId ) ; servers . add ( curServer ) ; } } catch ( SQLException e ) { e . printStackTrace ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } finally { try { if ( results != null ) { results . close ( ) ; } } catch ( Exception e ) { } try { if ( queryStatement != null ) { queryStatement . close ( ) ; } } catch ( Exception e ) { } } return servers ; }
Get the server redirects belonging to a server group