private static String getValueFromDB ( final String _key , final String _language ) { String ret = null ; try { boolean closeContext = false ; if ( ! Context . isThreadActive ( ) ) { Context . begin ( ) ; closeContext = true ; } final Connection con = Context . getConnection ( ) ; final PreparedStatement stmt = con . prepareStatement ( DBProperties . SQLSELECT ) ; stmt . setString ( 1 , _key ) ; stmt . setString ( 2 , _language ) ; final ResultSet resultset = stmt . executeQuery ( ) ; if ( resultset . next ( ) ) { final String defaultValue = resultset . getString ( 1 ) ; final String value = resultset . getString ( 2 ) ; if ( value != null ) { ret = value . trim ( ) ; } else if ( defaultValue != null ) { ret = defaultValue . trim ( ) ; } } else { final PreparedStatement stmt2 = con . prepareStatement ( DBProperties . SQLSELECTDEF ) ; stmt2 . setString ( 1 , _key ) ; final ResultSet resultset2 = stmt2 . executeQuery ( ) ; if ( resultset2 . next ( ) ) { final String defaultValue = resultset2 . getString ( 1 ) ; if ( defaultValue != null ) { ret = defaultValue . trim ( ) ; } } resultset2 . close ( ) ; stmt2 . close ( ) ; } resultset . close ( ) ; stmt . close ( ) ; con . commit ( ) ; con . close ( ) ; if ( closeContext ) { Context . rollback ( ) ; } } catch ( final EFapsException e ) { DBProperties . LOG . error ( "initialiseCache()" , e ) ; } catch ( final SQLException e ) { DBProperties . LOG . error ( "initialiseCache()" , e ) ; } return ret ; }
This method is initializing the cache .