...
Table of Contents |
---|
maxLevel | 3 |
---|
minLevel | 3 |
---|
location | top |
---|
style | border:1 | location | top |
---|
type | flat |
---|
separator | pipe |
---|
|
...
Syntax
...
Localtabgroup |
---|
Localtab |
---|
active | true |
---|
title | Connection Pool |
---|
| Code Block |
---|
| <DBLookup><dblookup>
<connection>
<pool>
<driver/>
<url/>
<user/>
<password/>
<property name="name" value="value"/>*
</pool>
</connection>
<statement>
<sql>select something from table where something_else = ?</sql>
<parameter [value="" | expression=""] type="CHAR|VARCHAR|LONGVARCHAR|NUMERIC|DECIMAL|BIT|TINYINT|SMALLINT|INTEGER|BIGINT|REAL|FLOAT|DOUBLE|DATE|TIME|TIMESTAMP"/>*
<result name="string" column="int|string"/>*
</statement>+
</DBLookup>dblookup> |
|
Localtab |
---|
| The syntax of the DBLookup mediator further differs based on whether the connection to the database is made using an external datasource or a Carbon datasource. Click on the relevant tab to view the required syntax. Localtabgroup |
---|
Localtab |
---|
| Code Block |
---|
| <DBLookup><dblookup>
<connection>
<pool>
<dsName/>
<icClass/>
<url/>
<user/>
<password/>
<property name="name" value="value"/>*
</pool>
</connection>
<statement>
<sql>select something from table where something_else = ?</sql>
<parameter [value="" | expression=""] type="CHAR|VARCHAR|LONGVARCHAR|NUMERIC|DECIMAL|BIT|TINYINT|SMALLINT|INTEGER|BIGINT|REAL|FLOAT|DOUBLE|DATE|TIME|TIMESTAMP"/>*
<result name="string" column="int|string"/>*
</statement>+
</DBLookup>dblookup>
|
|
Localtab |
---|
| Code Block |
---|
| <DBLookup><dblookup>
<connection>
<pool>
<dsName/>
</pool>
</connection>
<statement>
<sql>select something from table where something_else = ?</sql>
<parameter [value="" | expression=""] type="CHAR|VARCHAR|LONGVARCHAR|NUMERIC|DECIMAL|BIT|TINYINT|SMALLINT|INTEGER|BIGINT|REAL|FLOAT|DOUBLE|DATE|TIME|TIMESTAMP"/>*
<result name="string" column="int|string"/>*
</statement>+
</DBLookup>dblookup>
|
|
|
|
|
...
UI Configuration
The UI configuration of the DBLookup mediator changes depending on whether you connect to the database using a connection pool, or using a data source. Click on the relevant tab to view the required UI configuration.
...
Info |
---|
|
You can configure the mediator using XML. Click switch to source view in the Mediator window.
|
...
Examples
Code Block |
---|
|
<DBLookup<dblookup xmlns="http://ws.apache.org/ns/synapse">
<connection>
<pool>
<driver>org.apache.derby.jdbc.ClientDriver</driver>
<url>jdbc:derby://localhost:1527/esbdb;create=false</url>
<user>esb</user>
<password>esb</password>
</pool>
</connection>
<statement>
<sql>select * from company where name =?</sql>
<parameter expression="//m0:getQuote/m0:request/m0:symbol"
xmlns:m0="http://services.samples/xsd" type="VARCHAR"/>
<result name="company_id" column="id"/>
</statement>
</DBLookup>dblookup>
|
In this example, when a message is received by a proxy service with a DBLookup mediator configuration, it opens a connection to the database and executes the SQL query. The SQL query uses ? character for attributes that will be filled at runtime. The parameters define how to calculate the value of those attributes at runtime. In this sample, the DBLookup Mediator has been used to extract the id
of the company from the company database using the symbol which is evaluated using an XPath against the SOAP envelope.
...