camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > SQL
Date Wed, 16 Jan 2013 09:22:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/SQL">SQL</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (2)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-changed-lines" >h2. SQL <span class="diff-added-words"style="background-color:
#dfd;">Language</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br>The SQL support is added
by [JoSQL|http://josql.sourceforge.net/] and is primarily used for performing SQL queries
on in-memory objects. If you prefer to perform actual database queries then check out the
[JPA] component. <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{tip:title=Looking
for the SQL component} <br>Camel has both a [SQL] language and a [SQL Component]. This
page is about the SQL language. Click on [SQL Component] if you are looking for the component
instead. <br>{tip} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >To use SQL in your camel routes you
need to add the a dependency on *camel-josql* which implements the SQL language.  <br>
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="SQL-SQLLanguage"></a>SQL Language</h2>

<p>The SQL support is added by <a href="http://josql.sourceforge.net/" class="external-link"
rel="nofollow">JoSQL</a> and is primarily used for performing SQL queries on in-memory
objects. If you prefer to perform actual database queries then check out the <a href="/confluence/display/CAMEL/JPA"
title="JPA">JPA</a> component.</p>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><b>Looking for the SQL component</b><br
/>Camel has both a <a href="/confluence/display/CAMEL/SQL" title="SQL">SQL</a>
language and a <a href="/confluence/display/CAMEL/SQL+Component" title="SQL Component">SQL
Component</a>. This page is about the SQL language. Click on <a href="/confluence/display/CAMEL/SQL+Component"
title="SQL Component">SQL Component</a> if you are looking for the component instead.</td></tr></table></div>

<p>To use SQL in your camel routes you need to add the a dependency on <b>camel-josql</b>
which implements the SQL language. </p>

<p>If you use maven you could just add the following to your pom.xml, substituting the
version number for the latest &amp; greatest release (see <a href="/confluence/display/CAMEL/Download"
title="Download">the download page for the latest versions</a>).</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
  <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
  <span class="code-tag">&lt;artifactId&gt;</span>camel-josql<span
class="code-tag">&lt;/artifactId&gt;</span>
  <span class="code-tag">&lt;version&gt;</span>2.5.0<span class="code-tag">&lt;/version&gt;</span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<p>Camel supports <a href="http://en.wikipedia.org/wiki/SQL" class="external-link"
rel="nofollow">SQL</a> to allow an <a href="/confluence/display/CAMEL/Expression"
title="Expression">Expression</a> or <a href="/confluence/display/CAMEL/Predicate"
title="Predicate">Predicate</a> to be used in the <a href="/confluence/display/CAMEL/DSL"
title="DSL">DSL</a> or <a href="/confluence/display/CAMEL/Xml+Configuration" title="Xml
Configuration">Xml Configuration</a>. For example you could use SQL to create an
<a href="/confluence/display/CAMEL/Predicate" title="Predicate">Predicate</a>
in a <a href="/confluence/display/CAMEL/Message+Filter" title="Message Filter">Message
Filter</a> or as an <a href="/confluence/display/CAMEL/Expression" title="Expression">Expression</a>
for a <a href="/confluence/display/CAMEL/Recipient+List" title="Recipient List">Recipient
List</a>.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"queue:foo"</span>).setBody().sql(<span class="code-quote">"select
* from MyType"</span>).to(<span class="code-quote">"queue:bar"</span>)
</pre>
</div></div>

<p>And the spring DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
   <span class="code-tag">&lt;from uri=<span class="code-quote">"queue:foo"</span>/&gt;</span>
   <span class="code-tag">&lt;setBody&gt;</span>
       <span class="code-tag">&lt;sql&gt;</span>select * from MyType<span
class="code-tag">&lt;/sql&gt;</span>
   <span class="code-tag">&lt;/setBody&gt;</span>
   <span class="code-tag">&lt;to uri=<span class="code-quote">"queue:bar"</span>/&gt;</span>
</pre>
</div></div>

<h3><a name="SQL-Variables"></a>Variables</h3>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Variable </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> exchange </td>
<td class='confluenceTd'> Exchange </td>
<td class='confluenceTd'> the Exchange object </td>
</tr>
<tr>
<td class='confluenceTd'> in </td>
<td class='confluenceTd'> Message </td>
<td class='confluenceTd'> the exchange.in message </td>
</tr>
<tr>
<td class='confluenceTd'> out </td>
<td class='confluenceTd'> Message </td>
<td class='confluenceTd'> the exchange.out message </td>
</tr>
<tr>
<td class='confluenceTd'> the property key </td>
<td class='confluenceTd'> Object </td>
<td class='confluenceTd'> the Exchange properties </td>
</tr>
<tr>
<td class='confluenceTd'> the header key </td>
<td class='confluenceTd'> Object </td>
<td class='confluenceTd'> the exchange.in headers </td>
</tr>
<tr>
<td class='confluenceTd'> the variable key </td>
<td class='confluenceTd'> Object </td>
<td class='confluenceTd'> if any additional variables is added using <tt>setVariables</tt>
method </td>
</tr>
</tbody></table>
</div>


    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/SQL">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=54171&revisedVersion=10&originalVersion=9">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/SQL?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message