Examples of JDBCDataStore


Examples of org.geotools.jdbc.JDBCDataStore

        assertFalse(factory.canProcess(Collections.EMPTY_MAP));
        assertTrue(factory.canProcess(params));
    }
   
    public void testCreateDataStore() throws Exception {
        JDBCDataStore ds = factory.createDataStore( params );
        assertNotNull( ds );
        assertTrue(ds.getDataSource() instanceof ManageableDataSource);
    }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

    }

    public void testCreateDataStoreMVCC() throws Exception {
        Map clonedParams = new HashMap(params);
        clonedParams.put(H2DataStoreFactory.MVCC.key, true);
        JDBCDataStore ds = factory.createDataStore(clonedParams);
        assertNotNull(ds);
        final DataSource source = ds.getDataSource();
        assertNotNull(source);
        final DataSource wrapped = source.unwrap(DataSource.class);
        assertNotNull(wrapped);
        if (wrapped instanceof BasicDataSource) {
            final BasicDataSource basicSource = (BasicDataSource) wrapped;
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

        params.put(DBTYPE.key, factory.getDatabaseID());
        params.put(SQLServerDataStoreFactory.INTSEC.key, false);
       
        assertTrue(factory.canProcess(params));
       
        JDBCDataStore store = factory.createDataStore(params);
        assertNotNull(store);
        try {
            // check dialect
            assertTrue(store.getSQLDialect() instanceof SQLServerDialect);
           
            // force connection usage
            assertNotNull(store.getSchema("ft1"));
        } finally {
            store.dispose();
        }
    }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

        assertFalse(factory.canProcess(Collections.EMPTY_MAP));
        assertTrue(factory.canProcess(params));
    }
   
    public void testCreateDataStore() throws Exception {
        JDBCDataStore ds = factory.createDataStore( params );
        assertNotNull( ds );
    }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

        params.put(SCHEMA.key, db.getProperty(SCHEMA.key));

        params.put(DBTYPE.key, dbtype);

        assertTrue(factory.canProcess(params));
        JDBCDataStore store = factory.createDataStore(params);
        assertNotNull(store);
        try {
            // check dialect
            assertTrue(store.getSQLDialect() instanceof TeradataDialect);

            // force connection usage
            assertNotNull(store.getSchema(tname("ft1")));
        } finally {
            store.dispose();
        }
    }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

        params.put(PASSWD.key, db.getProperty("password"));
        params.put(DBTYPE.key, "oracle");
        params.put(GEOMETRY_METADATA_TABLE.key, "geometry_columns_test");

        assertTrue(factory.canProcess(params));
        JDBCDataStore store = factory.createDataStore(params);
        assertNotNull(store);
        try {
            // check dialect
            OracleDialect dialect = (OracleDialect) store.getSQLDialect();

            // check the metadata table has been set (other tests check it's actually working)
            assertEquals("geometry_columns_test", dialect.getGeometryMetadataTable());
        } finally {
            store.dispose();
        }
    }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

        params.put(USER.key, db.getProperty(USER.key));
        params.put(PASSWD.key, db.getProperty("password"));
        params.put(DBTYPE.key, dbtype);

        assertTrue(factory.canProcess(params));
        JDBCDataStore store = factory.createDataStore(params);
        assertNotNull(store);
        try {
            // check dialect
            assertTrue(store.getSQLDialect() instanceof OracleDialect);
            // force connection usage
            assertNotNull(store.getSchema(tname("ft1")));
        } finally {
            store.dispose();
        }
    }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

    private static final String CREATE_DROP_TESTDB = "gt2_create_drop_testdb";

    @Override
    protected boolean isOnline() throws Exception {
        PostgisNGDataStoreFactory factory =  new PostgisNGDataStoreFactory();
        JDBCDataStore closer = new JDBCDataStore();
        Class.forName(factory.getDriverClassName());
       
        // get host and port
        String host = fixture.getProperty(HOST.key);
        String port = fixture.getProperty(PORT.key);
        String user = fixture.getProperty(USER.key);
        String password = fixture.getProperty(PASSWD.key);
        String url = "jdbc:postgresql" + "://" + host + ":" + port + "/template1";
       
        Connection cx = null;
        Statement st = null;
        ResultSet rs = null;
        try {
            cx = DriverManager.getConnection(url, user, password);
            st = cx.createStatement();
            rs = st.executeQuery("select rolcreatedb from pg_authid where rolname = '" + user + "'");
            boolean canCreate = false;
            if(rs.next()) {
                canCreate = rs.getBoolean(1);
            }
            rs.close();
           
            if(!canCreate) {
                System.out.println("User " + user + " has no database creation options, skipping test");
                return false;
            }
           
            // creation options available, let's check if we have the postgis extension available then
            rs = st.executeQuery("select * from pg_available_extensions where name = 'postgis'");
            boolean hasPostgisExtension = false;
            if(rs.next()) {
                hasPostgisExtension = true;
            }
            rs.close();
           
            if(!hasPostgisExtension) {
                System.out.println("This version of postgresql has no postgis extension available (as in, one that can be used by the \"create extension\" command, skipping it");
                return false;
            }
           
            // drop the database if available
            rs = st.executeQuery("select * from pg_database where datname = 'create_drop_testdb'");
            boolean databaseExists = rs.next();
            rs.close();
            if(databaseExists) {
                st.execute("drop database " + CREATE_DROP_TESTDB);
            }
           
            return true;
        } catch(SQLException e) {
            System.out.println("Failed to check if the user has database creation privileges and postgis is an available extension");
            e.printStackTrace();
            return false;
        } finally {
            closer.closeSafe(rs);
            closer.closeSafe(cx);
            closer.closeSafe(st);
        }
    }
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

        // we can work with it
        assertTrue(factory.canProcess(params));
       
        // force database creation and check the store functions
        JDBCDataStore store = factory.createDataStore(params);
        assertNotNull(store);
        store.createSchema(DataUtilities.createType("test", "id:String,polygonProperty:Polygon:srid=32615"));
        store.getSchema("test");
       
        // now disconnect and drop
        store.dispose();
        factory.dropDatabase(params);
       
        // try to connect again, it must fail
        params.remove(PostgisNGDataStoreFactory.CREATE_DB_IF_MISSING.key);
        try {
            store = factory.createDataStore(params);
            store.getTypeNames();
            fail("This one should have failed, the database has just been dropped");
        } catch(Exception e) {
            // fine, it's what we expected
        }
       
View Full Code Here

Examples of org.geotools.jdbc.JDBCDataStore

    @Override
    protected void initializeDatabase() throws Exception {
        DataSource dataSource = getDataSource();
        Connection cx = dataSource.getConnection();
        try {
            PostGISDialect dialect = new PostGISDialect(new JDBCDataStore());
            postgisVersion = dialect.getVersion(cx);
            pgsqlVersion = dialect.getPostgreSQLVersion(cx);
        }
        finally {
            cx.close();
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.