public Configuration [ ] getConfigurations ( String name ) { ArrayList < Configuration > valuesList = new ArrayList < Configuration > ( ) ; logger . info ( "Getting data for {}" , name ) ; PreparedStatement statement = null ; ResultSet results = null ; try ( Connection sqlConnection = sqlService . getConnection ( ) ) { String queryString = "SELECT * FROM " + Constants . DB_TABLE_CONFIGURATION ; if ( name != null ) { queryString += " WHERE " + Constants . DB_TABLE_CONFIGURATION_NAME + "=?" ; } statement = sqlConnection . prepareStatement ( queryString ) ; if ( name != null ) { statement . setString ( 1 , name ) ; } results = statement . executeQuery ( ) ; while ( results . next ( ) ) { Configuration config = new Configuration ( ) ; config . setValue ( results . getString ( Constants . DB_TABLE_CONFIGURATION_VALUE ) ) ; config . setKey ( results . getString ( Constants . DB_TABLE_CONFIGURATION_NAME ) ) ; config . setId ( results . getInt ( Constants . GENERIC_ID ) ) ; logger . info ( "the configValue is = {}" , config . getValue ( ) ) ; valuesList . add ( config ) ; } } catch ( SQLException sqe ) { logger . info ( "Exception in sql" ) ; sqe . printStackTrace ( ) ; } finally { try { if ( results != null ) { results . close ( ) ; } } catch ( Exception e ) { } try { if ( statement != null ) { statement . close ( ) ; } } catch ( Exception e ) { } } if ( valuesList . size ( ) == 0 ) { return null ; } return valuesList . toArray ( new Configuration [ 0 ] ) ; }
Get the values for a particular configuration property