<?xml version="1.0" encoding="utf-8"?>

<!-- EngineVersion = Java version -->
<ApiConfig Name="Apache IoTDB"
           Slug="apache-iotdb-connector"
           Type="JDBC"
           Category="time-series"
           Id="A30E5F0D-62C1-5268-B2A5-82768FF0ABE5"
           Version="1"
           EngineVersion="8"
           Desc="Query Apache IoTDB with the official JDBC driver from Power BI, SQL Server Linked Server via ZappySys Data Gateway, Crystal Reports, SSRS, Azure Data Factory, and other ODBC tools -- almost no coding required."
           Logo="https://cdn.zappysys.com/api/Images/logos/apache-iotdb-connector.png"
           HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html">

    <VersionHistory>
      <Change Ver="1" Date="2026-09-14" Type="New">Initial JDBC Bridge catalog version. Hands-free Maven JAR download. Auth Notes and SQL examples for ODBC apps.</Change>
    </VersionHistory>
    <Template>
        <Param Name="DriverDownloadPageLink"
               Value="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
        <Param Name="MvnRepositoryDriverDownloadLink"
               Value="https://mvnrepository.com/artifact/org.apache.iotdb/iotdb-jdbc" />
        <Param Name="DriverDownloadLinks"
               Hidden="True"
               Value="iotdb-jdbc-2.0.8-jar-with-dependencies.jar=https://repo1.maven.org/maven2/org/apache/iotdb/iotdb-jdbc/2.0.8/iotdb-jdbc-2.0.8-jar-with-dependencies.jar" />
    </Template>

    <Auths>
        <Auth Name="Tree"
              Label="Tree model"
              ConnStr="jdbc:iotdb://[$HostName$]:[$Port$]/"
              HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html">
            <Params>
                <Param Name="DriverClass" Label="Driver class" Required="False" Value="org.apache.iotdb.jdbc.IoTDBDriver" Desc="Optional. Leave blank to auto-detect from the JAR unless SPI is ambiguous (e.g. org.apache.iotdb.jdbc.IoTDBDriver)." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
                <Param Name="DriverFilePaths" Editor="FileOpen" Label="JDBC driver file(s)" Required="True" Value="{DownloadFolder}\iotdb-jdbc-2.0.8-jar-with-dependencies.jar" Desc="Filled by the wizard after download. Separate multiple JARs with a semicolon (e.g. C:\ZappySys\Jdbc\MyConnector\driver.jar)." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
                <Param Name="HostName" Label="Host" Required="True" Value="MyHostName" Desc="JDBC host name or IP (e.g. MyHostName)." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
                <Param Name="Port" Label="TCP port" Required="True" Value="6667" Desc="JDBC port (e.g. 6667)." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
                <Param Name="UserName" Label="User name" Required="False" Desc="Database user. Leave empty if the server allows anonymous JDBC." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
                <Param Name="Password" Label="Password" Required="False" Secret="True" Desc="Database password. Leave empty if no password is required." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
            </Params>
            <Notes>
                <![CDATA[<p>Apache IoTDB (tree) JDBC from Power BI, SQL Server Linked Server via ZappySys Data Gateway, Crystal Reports, SSRS, Azure Data Factory, and other ODBC tools.</p>
<ol>
  <li>Note the IoTDB host and RPC port (default <code>6667</code>).</li><li>Create a user in IoTDB (<code>CREATE USER</code>) or use <code>root</code> in a lab only.</li><li>Tree model uses path-style time series. Switch to Table dialect Auth if you enabled table SQL.</li>
  <li>Finish the wizard. Then click <strong>Test Connection</strong> on the DSN Main UI (the wizard does not run Test Connection).</li><li>Done. You can query from C#, Python, PowerShell, and ODBC apps.</li>
</ol>]]>
            </Notes>
        </Auth>
        <Auth Name="Table"
              Label="Table dialect"
              ConnStr="jdbc:iotdb://[$HostName$]:[$Port$]/?sql_dialect=[$SqlDialect$]"
              HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html">
            <Params>
                <Param Name="DriverClass" Label="Driver class" Required="False" Value="org.apache.iotdb.jdbc.IoTDBDriver" Desc="Optional. Leave blank to auto-detect from the JAR unless SPI is ambiguous (e.g. org.apache.iotdb.jdbc.IoTDBDriver)." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
                <Param Name="DriverFilePaths" Editor="FileOpen" Label="JDBC driver file(s)" Required="True" Value="{DownloadFolder}\iotdb-jdbc-2.0.8-jar-with-dependencies.jar" Desc="Filled by the wizard after download. Separate multiple JARs with a semicolon (e.g. C:\ZappySys\Jdbc\MyConnector\driver.jar)." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
                <Param Name="HostName" Label="Host" Required="True" Value="MyHostName" Desc="JDBC host name or IP (e.g. MyHostName)." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
                <Param Name="Port" Label="TCP port" Required="True" Value="6667" Desc="JDBC port (e.g. 6667)." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
                <Param Name="SqlDialect" Label="SQL dialect" Required="False" Options="Notset=;Table=table;Tree=tree" Value="table" Desc="IoTDB SQL dialect (e.g. Table from the dropdown)." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
                <Param Name="UserName" Label="User name" Required="False" Desc="Database user. Leave empty if the server allows anonymous JDBC." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
                <Param Name="Password" Label="Password" Required="False" Secret="True" Desc="Database password. Leave empty if no password is required." HelpLink="https://iotdb.apache.org/UserGuide/latest/API/Programming-JDBC.html" />
            </Params>
            <Notes>
                <![CDATA[<p>Apache IoTDB (table) JDBC from Power BI, SQL Server Linked Server via ZappySys Data Gateway, Crystal Reports, SSRS, Azure Data Factory, and other ODBC tools.</p>
<ol>
  <li>Same host/port as tree. Append <code>sql_dialect=table</code> (already in this URL).</li><li>Fill user and password. Table dialect uses <code>SHOW TABLES</code> / relational SQL.</li>
  <li>Finish the wizard. Then click <strong>Test Connection</strong> on the DSN Main UI (the wizard does not run Test Connection).</li><li>Done. You can query from C#, Python, PowerShell, and ODBC apps.</li>
</ol>]]>
            </Notes>
        </Auth>
    </Auths>

    <Examples>
        <Example Default="True" Group="ODBC" Slug="list-tables" Label="List tables" HelpLink="https://iotdb.apache.org/UserGuide/latest/SQL-Manual/SQL-Manual.html">
            <Desc><![CDATA[<p>Lists tables available to this connection. Use this in Power BI or a SQL Server Linked Server to confirm the catalog before building reports.</p>]]></Desc>
            <Code>
                <![CDATA[SHOW TIMESERIES]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="select-rows" Label="Select rows" HelpLink="https://iotdb.apache.org/UserGuide/latest/SQL-Manual/SQL-Manual.html">
            <Desc><![CDATA[<p>Returns rows from <code>root.sg.d1</code>. Replace the identifier with your catalog object. Works in Excel, SSRS, and Crystal Reports.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT * FROM root.sg.d1]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="filter-rows" Label="Filter with WHERE" HelpLink="https://iotdb.apache.org/UserGuide/latest/SQL-Manual/SQL-Manual.html">
            <Desc><![CDATA[<p>Returns matching rows from <code>root.sg.d1</code>. Swap the column and literal for your schema.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT * FROM root.sg.d1
WHERE id = 1]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="join-tables" Label="Join tables" HelpLink="https://iotdb.apache.org/UserGuide/latest/SQL-Manual/SQL-Manual.html">
            <Desc><![CDATA[<p>Joins two tables on a key. Use in Azure Data Factory or SSIS when you need a combined extract.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT a.id, a.name, b.amount
FROM root.sg.d1 AS a
JOIN my_other_table AS b ON a.id = b.parent_id]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="group-by" Label="Aggregate with GROUP BY" HelpLink="https://iotdb.apache.org/UserGuide/latest/SQL-Manual/SQL-Manual.html">
            <Desc><![CDATA[<p>Counts rows per group. Typical Power BI import pattern before a visual.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT status, COUNT(*) AS row_count
FROM root.sg.d1
GROUP BY status]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="having" Label="Filter groups with HAVING" HelpLink="https://iotdb.apache.org/UserGuide/latest/SQL-Manual/SQL-Manual.html">
            <Desc><![CDATA[<p>Keeps groups whose count is at least 10.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT status, COUNT(*) AS row_count
FROM root.sg.d1
GROUP BY status
HAVING COUNT(*) >= 10]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="order-limit" Label="Order and limit" HelpLink="https://iotdb.apache.org/UserGuide/latest/SQL-Manual/SQL-Manual.html">
            <Desc><![CDATA[<p>Returns the first 100 rows ordered by a column. Useful for preview in Excel or Crystal Reports.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT * FROM root.sg.d1
ORDER BY id
LIMIT 100]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="count-all" Label="Count rows" HelpLink="https://iotdb.apache.org/UserGuide/latest/SQL-Manual/SQL-Manual.html">
            <Desc><![CDATA[<p>Returns the number of rows in <code>root.sg.d1</code>.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT COUNT(*) AS row_count FROM root.sg.d1]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="case-expr" Label="CASE expression" HelpLink="https://iotdb.apache.org/UserGuide/latest/SQL-Manual/SQL-Manual.html">
            <Desc><![CDATA[<p>Maps a column to labels with <code>CASE</code>.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT id,
       CASE WHEN status = 'A' THEN 'Active' ELSE 'Other' END AS status_label
FROM root.sg.d1]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="select-list" Label="Select specific columns" HelpLink="https://iotdb.apache.org/UserGuide/latest/SQL-Manual/SQL-Manual.html">
            <Desc><![CDATA[<p>Returns a column list instead of star. Prefer this in Linked Server views.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT id, name, status
FROM root.sg.d1]]>
            </Code>
        </Example>
    </Examples>
</ApiConfig>
