This example Mule service takes an HTTP request, queries Teradata and returns results in JSON format.
The Mule HTTP connector listens for HTTP GET requests with the form: http://<host>:8081/?lastname=<parameter>.
The HTTP connector passes the value of <parameter> as one of the message properties to a database connector.
The database connector is configured to extract this value and use it in this SQL query:
SELECT * FROM hr.employees WHERE LastName = :lastName
As you can see, we are using parameterized query with reference to the value of the parameter passed to the HTTP connector. So if the HTTP connector receives http://localhost:8081/?lastname=Smith, the SQL query will be:
SELECT * FROM employees WHERE LastName = 'Smith'
The database connector instructs the database server to run the SQL query, retrieves the result of the query, and passes it to the Transform message processor which converts the result to JSON. Since the HTTP connector is configured as request-response, the result is returned to the originating HTTP client.