Code example for ResultSet

Methods: getDouble, getString, next

0
            builder = new SimpleFeatureBuilder(IDX_FEATURE_TYPE);
            gf = new GeometryFactory();
        } 
 
        public void close() { 
            JDBCUtils.close(rs);
            JDBCUtils.close(st);
        } 
 
        public boolean hasNext() { 
            // the contract of the iterator does not say this will be 
            // called just once, we have to guard against multiple calls 
            if (!nextCalled)
                try { 
                    next = rs.next();
                    nextCalled = true;
                } catch (SQLException e) {
                    close(); 
                    throw new RuntimeException(
                            "Error while accessing next db record", e);
                } 
 
            return next;
        } 
 
        public Feature next() throws NoSuchElementException { 
            if (!nextCalled)
                hasNext(); 
            nextCalled = false;
            try { 
                double x = rs.getDouble(1);
                double y = rs.getDouble(2);
                builder.add(gf.createPoint(new Coordinate(x, y)));
                return builder.buildFeature(rs.getString(3));
            } catch (SQLException e) {
                close(); 
                throw new RuntimeException(
                        "Problems reading the geometry index"); 
            }