Examples of JDBCDataStore


Examples of org.geotools.jdbc.JDBCDataStore

    }
    /*
     * @see org.locationtech.udig.catalog.IService#getInfo(org.eclipse.core.runtime.IProgressMonitor)
     */
    protected IServiceMySQLInfo createInfo( IProgressMonitor monitor ) throws IOException {
        JDBCDataStore dataStore = getDS(); // load DataStore
        if (dataStore == null) {
            return null; // could not connect to provide info
        }
        rLock.lock();
        try {
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

        }
        if (adaptee.isAssignableFrom(IGeoResource.class)){
            return adaptee.cast(this);
        }
       
        JDBCDataStore dataStore = parent.getDataStore();
        if (adaptee.isAssignableFrom(DataStore.class)){
            return adaptee.cast(dataStore);
        }
        if (adaptee.isAssignableFrom(SimpleFeatureStore.class)) {
            FeatureSource<SimpleFeatureType, SimpleFeature> fs = dataStore.getFeatureSource(typename);
            if (fs instanceof FeatureStore){
                readOnly = false;
                return adaptee.cast(fs);
            }
            else {
                readOnly = true;
            }
            if (adaptee.isAssignableFrom(SimpleFeatureSource.class)){
                return adaptee.cast(dataStore.getFeatureSource(typename));
            }
        }
        if (adaptee.isAssignableFrom(Connection.class)){
          return service.resolve(adaptee, monitor);
        }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

    }
    /*
     * @see org.locationtech.udig.catalog.IService#getInfo(org.eclipse.core.runtime.IProgressMonitor)
     */
    protected IServiceInfo createInfo( IProgressMonitor monitor ) throws IOException {
        JDBCDataStore dataStore = getDS(monitor); // load ds
        if (dataStore == null) {
            return null;
        }
        rLock.lock();
        try {
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

        }
        if (adaptee.isAssignableFrom(IGeoResource.class)){
            return adaptee.cast(this);
        }
        if (adaptee.isAssignableFrom(SimpleFeatureStore.class)) {
            JDBCDataStore dataStore = getService().getDS(monitor);

            SimpleFeatureSource fs = dataStore.getFeatureSource(typename);

            if (fs instanceof SimpleFeatureStore){
                return adaptee.cast(fs);
            }
            if (adaptee.isAssignableFrom(SimpleFeatureSource.class)) {
                dataStore = getService().getDS(monitor);

                return adaptee.cast(dataStore.getFeatureSource(typename));
            }
        }
        return super.resolve(adaptee, monitor);
    }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

    class OracleResourceInfo extends IGeoResourceInfo {

        private SimpleFeatureType ft = null;
        OracleResourceInfo() throws IOException {
            JDBCDataStore dataStore = getService().getDS(null);
            ft = dataStore.getSchema(typename); // this may be broken in geotools?
            this.title = typename;
            try {
                FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore
                        .getFeatureSource(typename);
                ft = source.getSchema();
                bounds = (ReferencedEnvelope) source.getBounds();
                if (bounds == null) {
                    CoordinateReferenceSystem crs = null;
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

        params.put( JDBCDataStoreFactory.DBTYPE.key, "h2");
       
        H2DataStoreFactory fac =  new H2DataStoreFactory();
        fac.setBaseDirectory( getTestData().getDataDirectoryRoot() );
       
        JDBCDataStore ds = fac.createDataStore(params);
        try {
            if ( ds.getSchema("widgets") != null ) {
                return;
            }
        }
        catch( Exception e ) {
           
        }
       
        SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
        tb.setName( "widgets" );
        tb.setSRS( "EPSG:4326");
        tb.add( "g", Point.class );
        tb.add( "name", String.class );
       
        ds.createSchema( tb.buildFeatureType() );
       
        FeatureWriter fw = ds.getFeatureWriterAppend( "widgets", Transaction.AUTO_COMMIT );
        fw.hasNext();
        SimpleFeature sf = (SimpleFeature) fw.next();
        sf.setAttribute("g", new GeometryFactory().createPoint( new Coordinate(1,1)));
        sf.setAttribute( "name", "one");
        fw.write();
       
        fw.hasNext();
        sf = (SimpleFeature) fw.next();
        sf.setAttribute("g", new GeometryFactory().createPoint( new Coordinate(2,2)));
        sf.setAttribute( "name", "two");
        fw.write();
       
        fw.close();
        ds.dispose();
    }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

    private void clearTable(PostGisConfig cfg, String table) throws PostGisException, IOException, SQLException {
        DataStore ds_ = PostGISUtils.createDatastore(cfg);
        assertTrue(ds_ instanceof JDBCDataStore);
       
        JDBCDataStore ds= (JDBCDataStore) ds_;
        Connection connection = ds.getConnection(Transaction.AUTO_COMMIT);
        connection.commit();
        Statement statement = connection.createStatement();
        statement.executeUpdate("DROP TABLE IF EXISTS " + cfg.getSchema() + "." + table );
        connection.commit();
        ds.dispose();
    }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

    private long count(PostGisConfig cfg, String table) throws PostGisException, IOException, SQLException {
        DataStore ds_ = PostGISUtils.createDatastore(cfg);
        assertTrue(ds_ instanceof JDBCDataStore);
       
        JDBCDataStore ds= (JDBCDataStore) ds_;

        Connection connection = ds.getConnection(Transaction.AUTO_COMMIT);
        connection.commit();
        Statement statement = connection.createStatement();
        ResultSet rs = statement.executeQuery("SELECT count(*) FROM " + cfg.getSchema() + "." + table );
        rs.next();
        long ret = rs.getLong(1);
        ds.dispose();
        return ret;
    }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

    private void clearTable(PostGisConfig cfg, String table) throws PostGisException, IOException, SQLException {
        DataStore ds_ = PostGISUtils.createDatastore(cfg);
        assertTrue(ds_ instanceof JDBCDataStore);
       
        JDBCDataStore ds= (JDBCDataStore) ds_;

        Connection connection = ds.getConnection(Transaction.AUTO_COMMIT);
        connection.commit();
        Statement statement = connection.createStatement();
        statement.executeUpdate("DROP TABLE IF EXISTS " + cfg.getSchema() + "." + table );
        connection.commit();
        ds.dispose();
    }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

    private long count(PostGisConfig cfg, String table) throws PostGisException, IOException, SQLException {
        DataStore ds_ = PostGISUtils.createDatastore(cfg);
        assertTrue(ds_ instanceof JDBCDataStore);
       
        JDBCDataStore ds= (JDBCDataStore) ds_;

        Connection connection = ds.getConnection(Transaction.AUTO_COMMIT);
        connection.commit();
        Statement statement = connection.createStatement();
        ResultSet rs = statement.executeQuery("SELECT count(*) FROM " + cfg.getSchema() + "." + table );
        rs.next();
        long ret = rs.getLong(1);
        ds.dispose();
        return ret;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.