Data Source

A Data Source provides the information that the Weave server requires to connect to a databases.

Weave uses JDBC, a standard Java database API, to interact with databases and the data source configuration is used to provide Weave with the required JDBC settings to be able to connect and interact with a database.

Most of the settings required for a data source are specific to the database, and JDBC driver, that you are connecting to and the documentation for the driver should be consulted to determine the correct values, especially for the driver and url parameters.


Time filtering with SQL Server

If when filtering data from a SQL Server database you receive errors about the data types time and datetime being incompatible you can resolve this by setting sendTimeAsDatetime to false as a parameter in the connection URL, e.g.

<url>jdbc:sqlserver://sqls2014:1433;databaseName=GIS;sendTimeAsDatetime=false</url>

Timestamps with Oracle

The Oracle JDBC driver by default does not correctly follow the JDBC specification when it comes to handling timestamp columns, to force the Oracle JDBC driver to be compliant you should set the system property oracle.jdbc.J2EE13Compliant to true.

Weave will try and work around the problem (and generate a warning pointing to this page) but at the cost of performance overhead.

Generally, only read access is required when connecting to the database, some custom modules may require write access.

Connecting pooling can be enabled for the data source, so that rather than connecting to the database each time it needs to perform an operation the Weave server will instead create a collection of connections and keep them in a pool to be used when required.

Namespace

urn:com.cohga.server.datasource.jdbc#1.0

Tags

datasource

Properties

Name

Type

Required

Description

id

string

yes

Unique identifier

driver

string

no

The class name of the JDBC driver.

There are different JDBC drivers for different databases, and even more than one for some databases, so this value will depend upon what JDBC driver you're using.

This value is required if jndi is not set.

url

string

no

The connection URL. This is driver specific and will depend upon the database you're connecting to an the JDBC driver you're using.

This value is required if jndi is not set.

username

string

no

The userid used to connect to the database.

password

string

no

The password of the userid used to connect to the database

jndistringno

A JNDI resource name for a datasource created by the underlying application server.

If specified the other settings here are ignored.

Sub-tags

Name

Type

Cardinality

pool

ref urn:com.cohga.server.pool#1.0

0..1

Content

None

Notes

  • The database connection can be created in one of two ways. Either Weave is responsible for connecting to the database and managing the connection, or the underlying application server (Jetty, Tomcat, WebSphere, etc) is responsible for the connection.
  • If Weave is to be responsible for managing the connection then the appropriate JDBC driver must be installed in the platform\workspace\jdbc directory, and at least the driver and url settings must be specified in the Weave datasource configuration.
  • If the application server is responsible for managing the connections then the appropriate JDBC driver must be installed in the application server and a JNDI database connection created in the application server, and the jndi value set to the resource name for the application server datasource in the Weave datasource configuration.
  • The pool tag also support a maxAgeMillis property which specifies a limit on how long the database connection should be kept open for, note however that this check only occurs during connection validation, so testOnBorrowtestOnReturn and/or testWhileIdle must be set for the pool.


Examples

Connecting to Oracle

<jdbc:datasource id="datasource.oradev">
	<driver>oracle.jdbc.driver.OracleDriver</driver>
	<url><![CDATA[jdbc:oracle:thin:@1521:oradev:ORCL]]></url>
	<username>read</username>
	<password>ManD0lAuh</password>
	<pool:pool>
		<maxActive>15</maxActive>
		<minIdle>2</minIdle>
		<maxIdle>2</maxIdle>
		<testOnBorrow>true</testOnBorrow>
		<timeBetweenEvictionRunsMillis>60000</timeBetweenEvictionRunsMillis>
		<minEvictableIdleTimeMillis>1200000</minEvictableIdleTimeMillis>
		<whenExhaustedAction>grow</whenExhaustedAction>
	</pool:pool>
</jdbc:datasource>

Connecting to Postgres

<jdbc:datasource id="datasource.postgis">
	<driver>org.postgresql.Driver</driver>
	<url><![CDATA[jdbc:postgresql://postgis21:5432/mann]]></url>
	<username>gis</username>
	<password>gispassword</password>
	<schema>mann</schema>
	<pool:pool>
		<minIdle>2</minIdle>
		<maxIdle>4</maxIdle>
		<testOnBorrow>true</testOnBorrow>
		<testOnReturn>true</testOnReturn>
		<testWhileIdle>true</testWhileIdle>
		<timeBetweenEvictionRunsMillis>15000</timeBetweenEvictionRunsMillis>
		<minEvictableIdleTimeMillis>120000</minEvictableIdleTimeMillis>
		<whenExhaustedAction>grow</whenExhaustedAction>
	</pool:pool>
</jdbc:datasource>

Connecting to SQL Server (using the Microsoft SQL Server JDBC driver)

<jdbc:datasource id="sqlserver2012">
	<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
	<url><![CDATA[jdbc:sqlserver://sqls2012dev;databaseName=GIS]]></url>
	<username>gisadmin</username>
	<password>ENCTXTJJPCQPAJUCKKMABFJEBZJAKFCXGME</password>
	<pool:pool>
		<maxActive>4</maxActive>
		<minIdle>2</minIdle>
		<maxIdle>2</maxIdle>
		<testOnBorrow>true</testOnBorrow>
		<testOnReturn>true</testOnReturn>
		<testWhileIdle>true</testWhileIdle>
		<timeBetweenEvictionRunsMillis>60000</timeBetweenEvictionRunsMillis>
		<minEvictableIdleTimeMillis>1200000</minEvictableIdleTimeMillis>
		<whenExhaustedAction>block</whenExhaustedAction>
	</pool:pool>
</jdbc:datasource>

Connecting to a directory of dBase tables

<jdbc:datasource id="datasource.dbf">
	<driver>com.hxtt.sql.dbf.DBFDriver</driver>
	<url><![CDATA[jdbc:dbf:////u1/data/dbf/]]></url>
</jdbc:datasource>

Exposing a JNDI resource declared elsewhere as a data source to Weave

<jdbc:datasource id="datasource.jndi">
	<jndi>java:comp/env/jdbc/uat</jndi>
</jdbc:datasource>