Database Services

Description

Database services allow to create pvmanager services based on database queries. Each service represents a database and each method represents a query. The query results are automatically mapped to VTable, based on the metadata coming from the database driver.

XML syntax

Here is an example of an XML file describing a jdbc service:

<?xml version="1.0" encoding="UTF-8"?>
<jdbcService ver="1" name="jdbcSample" description="A test service">
<jdbcUrl>jdbc:mysql://localhost/test?user=username&amp;password=mypwd</jdbcUrl>
<methods>
<method name="query" description="A test query">
<query>SELECT * FROM Data</query>
<result name="result" description="The query result"/>
</method>
<method name="insert" description="A test insert query">
<query>INSERT INTO `test`.`Data` (`Name`, `Index`, `Value`) VALUES (?, ?, ?)</query>
<argument name="name" description="The name" type="VString"/>
<argument name="index" description="The index" type="VNumber"/>
<argument name="value" description="The value" type="VNumber"/>
</method>
</methods>
</jdbcService>

Each service method correspon to one command, with specific mappings. A service is a collection of different mehods.

Syntax Description
jdbcService Version is required to be "1". Name and description of the service are required
jdbcUrl Database url for the JDBC driver. The correct driver must have been initialized. The syntax is driver dependent. Consult JDBC documentation.
methods List of methods must be provided
method Each method must have a name and a description
query The query passed to the database driver. It can contain parameters marked as '?'. Parameters are distinguished by position.
argument Arguments are optional, but they must match the number of '?' specified in the query. Each argument must have a name, a description and a type. Supported type include: VString, VNumber.
result Result must include a name and a description. If the result is present, the query is executed expecting a result, and the result is mapped to a VTable.