private static boolean getNumberGeneratorFromDB(final String _sql,
                                                    final Object _criteria)
        throws CacheReloadException
    {
        boolean ret = false;
        Connection con = null;
        try {
            con = Context.getConnection();
            PreparedStatement stmt = null;
            try {
                stmt = con.prepareStatement(_sql);
                stmt.setObject(1, _criteria);
                final ResultSet rs = stmt.executeQuery();
                if (rs.next()) {
                    final long id = rs.getLong(1);
                    final String name = rs.getString(2).trim();
                    final String uuid = rs.getString(3).trim();
                    final String format = rs.getString(4).trim();
                    NumberGenerator.LOG.debug("read NumberGenerator '{}' (id = {}), format = '{}'", name, id, format);
                    final NumberGenerator generator = new NumberGenerator(id, name, uuid, format);
                    NumberGenerator.cacheNumberGenerator(generator);
                }
                ret = true;
                rs.close();
            } finally {
                if (stmt != null) {
                    stmt.close();
                }
            }
            con.commit();
        } catch (final SQLException e) {
            throw new CacheReloadException("could not read roles", e);
        } catch (final EFapsException e) {
            throw new CacheReloadException("could not read roles", e);
        } finally {
            try {
                if (con != null && !con.isClosed()) {
                    con.close();
                }
            } catch (final SQLException e) {
                throw new CacheReloadException("Cannot read a type for an attribute.", e);
            }
        }
        return ret;
    }
private static boolean getNumberGeneratorFromDB ( final String _sql , final Object _criteria ) throws CacheReloadException { boolean ret = false ; Connection con = null ; try { con = Context . getConnection ( ) ; PreparedStatement stmt = null ; try { stmt = con . prepareStatement ( _sql ) ; stmt . setObject ( 1 , _criteria ) ; final ResultSet rs = stmt . executeQuery ( ) ; if ( rs . next ( ) ) { final long id = rs . getLong ( 1 ) ; final String name = rs . getString ( 2 ) . trim ( ) ; final String uuid = rs . getString ( 3 ) . trim ( ) ; final String format = rs . getString ( 4 ) . trim ( ) ; NumberGenerator . LOG . debug ( "read NumberGenerator '{}' (id = {}), format = '{}'" , name , id , format ) ; final NumberGenerator generator = new NumberGenerator ( id , name , uuid , format ) ; NumberGenerator . cacheNumberGenerator ( generator ) ; } ret = true ; rs . close ( ) ; } finally { if ( stmt != null ) { stmt . close ( ) ; } } con . commit ( ) ; } catch ( final SQLException e ) { throw new CacheReloadException ( "could not read roles" , e ) ; } catch ( final EFapsException e ) { throw new CacheReloadException ( "could not read roles" , e ) ; } finally { try { if ( con != null && ! con . isClosed ( ) ) { con . close ( ) ; } } catch ( final SQLException e ) { throw new CacheReloadException ( "Cannot read a type for an attribute." , e ) ; } } return ret ; }
@param _sql sql statement to be executed
@param _criteria filter criteria
@throws CacheReloadException on error
@return false