3. DataStores

A DataStore represents a single, physical, source of geographic data. It can consist of one or more FeatureTypes (or layers). A FeatureType can be a table (as in a database), a single file (as in a Shapefile), a directory (as in a VPF library). The DataStore construct is used so that you do not need to define connection parameters for each and every table in a large database. Instead you define them in the DataStore, and each FeatureType (table) refers to the DataStore that defines those parameters. In the case of Shapefiles, where each file can only contain one FeatureType, this may seem to be a bit of overkill, but to be in line with the rest we define the connection parameters in the Store and the rest in the FeatureType. Each available DataStore is discussed separately, as each has its own parameters and tricks, and you are likely only interested in one or two. But all have a few common parameters. (source: GeoServer Documentation)

As you can see in all the datastore examples, the datastore tag itself has three attributes:

The only difference between each type of datastore is the list of connection parameters that are required for the datastore to create a connection. Depending on the type of parameters, GeoServer itself decides what type of datastore should be created to suit them.

3.1. Shapefile DataStore

The Shapefile DataStore refers to a single ESRI Shapefile. The most important connection parameter is the URL that identifies the location of the Shapefile.

<datastore namespace = "shpex" enabled = "true" id = "road_shapeDS" >
   <connectionParams>
     <parameter value = "file:data/featureTypes/states/roads.shp" name = "url"  /
   </connectionParams>
 </datastore>

In this example the URL refers to the shape file by a relative path. The relative path is resolved relative to the web application directory of the MAJAS installation.

3.2. PostGIS DataStore

The PostGIS DataStore refers to a single Postgis database (a Postgresql database with the Postgis spatial extension). Most of the parameters of this DataStore are the JDBC connection parameters.

<datastore namespace = "postgis" enabled = "true" id = "PgTestDS" >
   <connectionParams>
     <parameter value = "postgis" name = "namespace"  />
     <parameter value = "myname" name = "user"  />
     <parameter value = "pgtest" name = "database"  />
     <parameter value = "change_me" name = "passwd"  />
     <parameter value = "localhost" name = "host"  />
     <parameter value = "5432" name = "port"  />
     <parameter value = "postgis" name = "dbtype"  />
   </connectionParams>
 </datastore>

Note the dbtype parameter. Its value should always be "postgis" for a PostGIS DataStore.

3.3. Oracle Spatial DataStore

The Oracle Spatial DataStore refers to an Oracle Instance and schema (if specified).

<datastore namespace = "oracle" enabled = "true" id = "OraTestDS" >
   <connectionParams>
     <!-- required parameters -->
     <parameter value = "myname" name = "user"  />
     <parameter value = "change_me" name = "passwd"  />
     <!-- dbtype must be "oracle" for Oracle DataStore -->
     <parameter value = "oracle" name = "dbtype"  />
     
     <!-- Optional parameters -->
     <parameter value = "myschema" name = "schema"  />
     
     <!-- the Oracle Instance (Service ID)-->
     <parameter value = "orainst" name="instance"/> 
     
     <parameter value = "localhost" name = "host"  />
     <parameter value = "152" name = "port"  />
   </connectionParams>
 </datastore>

3.4. WMS DataStore

The WMS Datastore refers to an online Web Map Service.

<datastore namespace = "wms" enabled = "true" id = "demo_wms" >
    <abstract>Demo WMS Datastore</abstract>
    <connectionParams>
        <parameter value = "http://some.wms.com/wms.aspx" name = "baseWMSurl" />

        <!-- Optional parameters -->
        <parameter value = "1.1.1" name = "version" />
        <parameter value = "image/gif" name = "format" />
        <parameter value = "EPSG:31370" name = "srs" />
        <parameter value = "10.40.101.1" name = "proxyHost" />
    </connectionParams>
</datastore>

Explanation of all the parameters:

  • baseWMSurl: The url at which the WMS can be reached.

  • version (optional): The WMS protocol you wish to use. If no protocol is given, MAJAS will automatically ask the WMS server which versions are allowed, an pick the most recent one. Supported versions are 1.0.0, 1.1.0, 1.1.1 and 1.3.0.

  • srs (optional): The Spatial Reference System. If none is given, the WMS' default will be used.

  • proxyHost (optional): This option allows you to use a proxy server for traffic from and towards the WMS server.

3.5. WFS DataStore

<datastore namespace = "wfs" enabled = "true" id = "demo_wfs" >
    <abstract>Demo WFS Datastore</abstract>
    <connectionParams>
        <parameter value = "http://some.wfs.com/wfs?request=getcapabilities&amp;service=wfs&amp;version=1.0.0" name = "WFSDataStoreFactory:GET_CAPABILITIES_URL" />

        <!-- Optional parameters -->
        <parameter value = "null" name = "WFSDataStoreFactory:PROTOCOL" />
        <parameter value = "some_user" name = "WFSDataStoreFactory:USERNAME" />
        <parameter value = "some_pass" name = "WFSDataStoreFactory:PASSWORD" />
        <parameter value = "2000" name = "WFSDataStoreFactory:TIMEOUT" />
        <parameter value = "15" name = "WFSDataStoreFactory:BUFFER_SIZE" />
        <parameter value = "false" name = "WFSDataStoreFactory:TRY_GZIP" />
        <parameter value = "false" name = "WFSDataStoreFactory:LENIENT" />
    </connectionParams>
</datastore>

Explanation of all the parameters:

  • WFSDataStoreFactory:GET_CAPABILITIES_URL: Represents a URL to the getCapabilities document or a server instance.

  • WFSDataStoreFactory:PROTOCOL: Sets a preference for the HTTP protocol to use when requesting WFS functionality. Set this value to Boolean.TRUE for POST, Boolean.FALSE for GET or NULL for AUTO.

  • WFSDataStoreFactory:USERNAME: This allows the user to specify a username. This param should not be used without the password param.

  • WFSDataStoreFactory:PASSWORD: This allows the user to specify a password. This param should not be used without the username param.

  • WFSDataStoreFactory:TIMEOUT: This allows the user to specify a timeout in milliseconds. This param has a default value of 3000ms.

  • WFSDataStoreFactory:BUFFER_SIZE: This allows the user to specify a buffer size in features. This param has a default value of 10 features.

  • WFSDataStoreFactory:TRY_GZIP: Indicates that datastore should use gzip to transfer data if the server supports it. Default is true.

  • WFSDataStoreFactory:LENIENT: Indicates that datastore should do its best to create features from the provided data even if it does not accurately match the schema. Errors will be logged but the parsing will continue if this is true. Default is false.