public Profile [ ] getProfilesForServerName ( String serverName ) throws Exception { int profileId = - 1 ; ArrayList < Profile > returnProfiles = new ArrayList < Profile > ( ) ; PreparedStatement queryStatement = null ; ResultSet results = null ; try ( Connection sqlConnection = sqlService . getConnection ( ) ) { queryStatement = sqlConnection . prepareStatement ( "SELECT " + Constants . GENERIC_PROFILE_ID + " FROM " + Constants . DB_TABLE_SERVERS + " WHERE " + Constants . SERVER_REDIRECT_SRC_URL + " = ? GROUP BY " + Constants . GENERIC_PROFILE_ID ) ; queryStatement . setString ( 1 , serverName ) ; results = queryStatement . executeQuery ( ) ; while ( results . next ( ) ) { profileId = results . getInt ( Constants . GENERIC_PROFILE_ID ) ; Profile profile = ProfileService . getInstance ( ) . findProfile ( profileId ) ; returnProfiles . add ( profile ) ; } } catch ( SQLException e ) { throw e ; } finally { try { if ( results != null ) { results . close ( ) ; } } catch ( Exception e ) { } try { if ( queryStatement != null ) { queryStatement . close ( ) ; } } catch ( Exception e ) { } } if ( returnProfiles . size ( ) == 0 ) { return null ; } return returnProfiles . toArray ( new Profile [ 0 ] ) ; }
This returns all profiles associated with a server name