<html>
<head>
    <base href="https://docs.jboss.org/author">
            <link rel="stylesheet" href="/author/s/en/2172/19/5/_/styles/combined.css?spaceKey=TEIID&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://docs.jboss.org/author/display/TEIID/Phoenix+Data+Sources">Phoenix Data Sources</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://docs.jboss.org/author/display/~kylin">Kylin Soong</a>
    </h4>
        <br/>
                         <h4>Changes (5)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-unchanged" >h1. Phoenix Data Sources <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The following is a example for setting up Phoenix Data Sources, which is precondition for [Apache HBase Translator|TEIID:JDBC Data Sources]. In addition to the Data Sources set up, this article also cover mapping Phoenix table to an existing HBase table and creating a new Phoenix table. <br> <br>There are configuration templates for Phoenix data sources in the  &quot;&lt;jboss-install&gt;/docs/teiid/datasources&quot; directory. A complete  description how a data source can be added into JBoss AS7.x is also  described&amp;nbsp;[here|http://community.jboss.org/docs/DOC-16657]. <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h1. Configuring a Phoenix data source in JBoss/WildFly (JBoss AS 7.x or later) <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >Configuring a Phoenix data source is nearly identical to configuring [TEIID:JDBC Data Sources].  The first step is deploying the Phoenix driver jar. <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;"> Use the following command using the</span> <span class="diff-added-words"style="background-color: #dfd;">Using below</span> CLI <span class="diff-added-words"style="background-color: #dfd;">command</span> to deploy Phoenix driver: <br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >The Driver jar can be download from [phoenix document.|http://phoenix.apache.org/] <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The second steps is creating the Data Source base on above deployed driver, which is also like creating [JDBC Data Source|TEIID:JDBC Data Sources]. Execute the following CLI command: <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The second steps is creating the Data Source base on above deployed driver, which is also like creating [JDBC Data Source|TEIID:JDBC Data Sources]. Using below CLI command to create Data Source: <br> <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br>/subsystem=datasources/data-source=phoenixDS:add(jndi-name=java:/phoenixDS,  driver-name=phoenix-[version].jar, driver-class=org.apache.phoenix.jdbc.PhoenixDriver, connection-url=jdbc:phoenix:{zookeeper quorum server},user-name={user}, password={password}) <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >For more about mapping Phoenix table to an existing HBase table please refer to the [phoenix documentation|http://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table]. <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >h1. Creating <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">A New</span> <span class="diff-added-words"style="background-color: #dfd;">a new</span> Phoenix table <br></td></tr>
            <tr><td class="diff-unchanged" > <br>Creating a new Phoenix table is just like mapping to an existing HBase table.  Phoenix will create any metadata (table, column families) that do not exist.  Similar to the above example the DDL to create the Phoenix/HBase Customer table would be: <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="PhoenixDataSources-PhoenixDataSources"></a>Phoenix Data Sources</h1>

<p>The following is a example for setting up Phoenix Data Sources, which is precondition for <a href="/author/display/TEIID/JDBC+Data+Sources" title="JDBC Data Sources">Apache HBase Translator</a>. In addition to the Data Sources set up, this article also cover mapping Phoenix table to an existing HBase table and creating a new Phoenix table.</p>

<p>There are configuration templates for Phoenix data sources in the  "&lt;jboss-install&gt;/docs/teiid/datasources" directory. A complete  description how a data source can be added into JBoss AS7.x is also  described&nbsp;<a href="http://community.jboss.org/docs/DOC-16657" class="external-link" rel="nofollow">here</a>.</p>

<h1><a name="PhoenixDataSources-ConfiguringaPhoenixdatasourceinJBoss%2FWildFly%28JBossAS7.xorlater%29"></a>Configuring a Phoenix data source in JBoss/WildFly (JBoss AS 7.x or later)</h1>

<p>Configuring a Phoenix data source is nearly identical to configuring <a href="/author/display/TEIID/JDBC+Data+Sources" title="JDBC Data Sources">JDBC Data Sources</a>.  The first step is deploying the Phoenix driver jar. Using below CLI command to deploy Phoenix driver:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
deploy /path/to/phoenix-[version]-client.jar
</pre>
</div></div>

<p>The Driver jar can be download from <a href="http://phoenix.apache.org/" class="external-link" rel="nofollow">phoenix document.</a></p>


<p>The second steps is creating the Data Source base on above deployed driver, which is also like creating <a href="/author/display/TEIID/JDBC+Data+Sources" title="JDBC Data Sources">JDBC Data Source</a>. Using below CLI command to create Data Source:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
/subsystem=datasources/data-source=phoenixDS:add(jndi-name=java:/phoenixDS,  driver-name=phoenix-[version].jar, driver-class=org.apache.phoenix.jdbc.PhoenixDriver, connection-url=jdbc:phoenix:{zookeeper quorum server},user-name={user}, password={password})
</pre>
</div></div>

<p>Please make sure the URL, Driver, and other properties are configured correctly:</p>

<ul>
        <li>jndi-name - The JNDI name need to match the JNDI name you used in VDB</li>
</ul>


<ul>
        <li>driver-name - The Driver name need to match the driver you deployed in above steps</li>
</ul>


<ul>
        <li>driver-class - The Driver Class, the value should be <em>org.apache.phoenix.jdbc.PhoenixDriver</em></li>
</ul>


<ul>
        <li>connection-url - The URL need to match the HBase zookeeper quorum server, the format like <em>jdbc:phoenix [ :&lt;zookeeper quorum&gt; [ :&lt;port number&gt; ] [ :&lt;root node&gt; ] ]</em>, '<em>jdbc:phoenix:127.0.0.1:2181</em>' is a example</li>
</ul>


<ul>
        <li>user-name/password - The user credentials for Phoenix Connection</li>
</ul>


<h1><a name="PhoenixDataSources-MappingPhoenixtabletoanexistingHBasetable"></a>Mapping Phoenix table to an existing HBase table</h1>

<p>Mapping Phoenix table to an existing HBase table has 2 steps.  The first step is installing phoenix-[version]-server.jar to the classpath of every HBase region server.  An easy way to do this is to copy it into the HBase lib - for more details please refer to the <a href="http://phoenix.apache.org/download.html" class="external-link" rel="nofollow">phoenix documentation</a>.</p>

<p>The second step is executing the DDL to map a Phoenix table to an existing HBase table.  The DDL can either be executed via <a href="http://phoenix.apache.org/download.html" class="external-link" rel="nofollow">Phoenix Command Line</a>, or executed by JDBC.</p>

<p>The Following is a example for mapping an existing HBase Customer with the following structure:</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<td class='confluenceTd'> Row Key </td>
<td class='confluenceTd'> customer </td>
<td class='confluenceTd'> sales </td>
</tr>
<tr>
<td class='confluenceTd'> ROW_ID </td>
<td class='confluenceTd'> name </td>
<td class='confluenceTd'> city </td>
<td class='confluenceTd'> product </td>
<td class='confluenceTd'> amount </td>
</tr>
<tr>
<td class='confluenceTd'> 101 </td>
<td class='confluenceTd'> John White </td>
<td class='confluenceTd'> Los Angeles, CA </td>
<td class='confluenceTd'> Chairs </td>
<td class='confluenceTd'> $400.00 </td>
</tr>
<tr>
<td class='confluenceTd'> 102 </td>
<td class='confluenceTd'> Jane Brown </td>
<td class='confluenceTd'> Atlanta, GA </td>
<td class='confluenceTd'> Lamps </td>
<td class='confluenceTd'> $200.00 </td>
</tr>
<tr>
<td class='confluenceTd'> 103 </td>
<td class='confluenceTd'> Bill Green </td>
<td class='confluenceTd'> Pittsburgh, PA </td>
<td class='confluenceTd'> Desk </td>
<td class='confluenceTd'> $500.00 </td>
</tr>
<tr>
<td class='confluenceTd'> 104 </td>
<td class='confluenceTd'> Jack Black </td>
<td class='confluenceTd'> St. Louis, MO </td>
<td class='confluenceTd'> Bed </td>
<td class='confluenceTd'> $1,600.00 </td>
</tr>
</tbody></table>
</div>



<p>As depicted above, the HBase <em>Customer</em> table have 2 column families, <em>customer</em> and <em>sales</em>, and each has 2 column qualifiers, <em>name</em>, <em>city</em>, <em>product</em> and <em>amount</em> respectively. We can map this Table to Phoenix via DDL:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
CREATE TABLE IF NOT EXISTS "Customer"("ROW_ID" VARCHAR PRIMARY KEY, "customer"."city" VARCHAR, "customer"."name" VARCHAR, "sales"."amount" VARCHAR, "sales"."product" VARCHAR)
</pre>
</div></div>
<p>For more about mapping Phoenix table to an existing HBase table please refer to the <a href="http://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table" class="external-link" rel="nofollow">phoenix documentation</a>.</p>

<h1><a name="PhoenixDataSources-CreatinganewPhoenixtable"></a>Creating a new Phoenix table</h1>

<p>Creating a new Phoenix table is just like mapping to an existing HBase table.  Phoenix will create any metadata (table, column families) that do not exist.  Similar to the above example the DDL to create the Phoenix/HBase Customer table would be:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
CREATE TABLE IF NOT EXISTS "Customer"("ROW_ID" VARCHAR PRIMARY KEY, "customer"."city" VARCHAR, "customer"."name" VARCHAR, "sales"."amount" VARCHAR, "sales"."product" VARCHAR)
</pre>
</div></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://docs.jboss.org/author/users/removespacenotification.action?spaceKey=TEIID">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://docs.jboss.org/author/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://docs.jboss.org/author/display/TEIID/Phoenix+Data+Sources">View Online</a>
        |
        <a href="https://docs.jboss.org/author/pages/diffpagesbyversion.action?pageId=88866974&revisedVersion=11&originalVersion=10">View Changes</a>
                |
        <a href="https://docs.jboss.org/author/display/TEIID/Phoenix+Data+Sources?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>