Load Data From Databases
Basic Syntax
The data-source command <xml-from-database>
fetches rows from a database and transforms rows and columns into XML.
Currently only MySQL and PostgreSQL are supported. Other databases would require other client JARs that are not provided in the current version of the software.
Alternative option using the environment-variable to connect to your local endpoints database - in this example (sql!) fetching request details from the request-log:
<jdbc-connection-string> specifies how to connect to the database to perform the query. This element is mandatory.
If it is present with no attributes, the body of the tab specifies the JDBC URL. Using a CDATA section is recommended to avoid having to perform XML escaping. Don't forget that username and password values must be URL-escaped.
If it is has an attribute
from-environment-variable="foo"
then the environment variable with that name is read and should contain the JDBC URL. Note that endpoints parameters are NOT expanded in the name of the variable name, to prevent an attacker having access to other environment variables.
<sql> should be self-explanatory :-)
Endpoint parameters are NOT expanded as that would allow SQL injection attacks.
For PostgreSQL, for non-string parameters, ?::int or ?::uuid it is necessary to cast the string supplied by the endpoint parameter into the right type for PostgreSQL.
Zero or more <param> elements, whose body are the contents of any "?" in the <sql> element. Here, endpoint parameters ARE expanded.
Generated output looks like this:
By default the root-tag of the generated output is <xml-from-database>. Use the optional tag attribute to generate any different root-tag:
Last updated