public List < ServerGroup > tableServerGroups ( int profileId ) { ArrayList < ServerGroup > serverGroups = new ArrayList <> ( ) ; PreparedStatement queryStatement = null ; ResultSet results = null ; try ( Connection sqlConnection = sqlService . getConnection ( ) ) { queryStatement = sqlConnection . prepareStatement ( "SELECT * FROM " + Constants . DB_TABLE_SERVER_GROUPS + " WHERE " + Constants . GENERIC_PROFILE_ID + " = ? " + "ORDER BY " + Constants . GENERIC_NAME ) ; queryStatement . setInt ( 1 , profileId ) ; results = queryStatement . executeQuery ( ) ; while ( results . next ( ) ) { ServerGroup curServerGroup = new ServerGroup ( results . getInt ( Constants . GENERIC_ID ) , results . getString ( Constants . GENERIC_NAME ) , results . getInt ( Constants . GENERIC_PROFILE_ID ) ) ; curServerGroup . setServers ( tableServers ( profileId , curServerGroup . getId ( ) ) ) ; serverGroups . add ( curServerGroup ) ; } } catch ( SQLException e ) { e . printStackTrace ( ) ; } finally { try { if ( results != null ) { results . close ( ) ; } } catch ( Exception e ) { } try { if ( queryStatement != null ) { queryStatement . close ( ) ; } } catch ( Exception e ) { } } return serverGroups ; }
Return all server groups for a profile