The SQLExecutor Visitor class Data can be used to perform event driven read and write operations on a DataSource, using data in the bean context as the query/update parameters.
Configuration Example
| Code Block |
|---|
<resource-config selector="customer-details">
<resource>org.milyn.routing.db.SQLExecutor</resource>
<param name="executeBefore">true</param>
<param name="datasource">DBExtractTransformLoadDS</param>
<param name="statement">select ORDERNUMBER from ORDERS where ORDERNUMBER = ${order.orderNum}</param>
<param name="resultSetName">orderExistsRS</param>
</resource-config>
|
Parameter | Description |
|---|---|
datasource | The name of the datasource configuration to use. See datasource section below. |
statment | The sql statement to be executed. Supports templating. |
resultSetName | If the statement is a query statement then the ResultSet will be bound with this id in the ExecutionContext. Must be specified if the 'statement' is a query statement, otherwise it is optional. |
Datasource Configuration Example
| Code Block |
|---|
<resource-config selector="$document">
<resource>org.milyn.db.DirectDataSource</resource>
<param name="datasource">DBExtractTransformLoadDS</param>
<param name="driver">org.hsqldb.jdbcDriver</param>
<param name="url">jdbc:hsqldb:hsql://localhost:9201/milyn-hsql-9201</param>
<param name="username">sa</param>
<param name="password"></param>
<param name="autoCommit">false</param>
</resource-config>
|
Resource is here an implementation of org.milyn.db.AbstractDataSource. There are currently two implementations, DirectDataSource and JndiDataSource.
Parameter | Description |
|---|---|
datasource | name for this datasource. WIll be used by other resouce-configs to refer to this datasource. |
driver | the name of the JDBC driver class. |
url | the JDBC URL. |
username | username for the database connection. |
password | password for the database connection. |
autocommit | should auto commit be enabled. |
For a complete working example of database routing please see the db-extract-transform-load example. from and written/routed to a database using the <db:executor> configuration from the http://www.milyn.org/xsd/smooks/db-routing-1.1.xsd namespace. The <db:executor> requires a Datasource to be configured. This is done via the <ds:direct> and <ds:JNDI> configurations from the http://www.milyn.org/xsd/smooks/datasource-1.1.xsd configuration namespace.
See the "Routing to a Database" section.