<?xml version="1.0" encoding="utf-8"?>

<!-- EngineVersion = Java version -->
<ApiConfig Name="InfluxDB 3"
           Slug="influxdb3-connector"
           Type="JDBC"
           Category="time-series"
           Id="4CB30B87-717A-505D-AD5D-48923EBF4F4F"
           Version="1"
           EngineVersion="11"
           Desc="Query InfluxDB 3 with SQL over Arrow Flight JDBC 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/influxdb3-connector.png"
           HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/">

    <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://arrow.apache.org/docs/java/flight_sql_jdbc_driver.html" />
        <Param Name="MvnRepositoryDriverDownloadLink"
               Value="https://mvnrepository.com/artifact/org.apache.arrow/flight-sql-jdbc-driver" />
        <Param Name="DriverDownloadLinks"
               Hidden="True"
               Value="flight-sql-jdbc-driver-19.0.0.jar=https://repo1.maven.org/maven2/org/apache/arrow/flight-sql-jdbc-driver/19.0.0/flight-sql-jdbc-driver-19.0.0.jar" />
    </Template>

    <Auths>
        <Auth Name="FlightSql"
              Label="Flight SQL (token)"
              ConnStr="jdbc:arrow-flight-sql://[$HostName$]:[$Port$]?useEncryption=true"
              HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/">
            <Params>
                <Param Name="DriverClass" Label="Driver class" Required="False" Value="org.apache.arrow.driver.jdbc.ArrowFlightJdbcDriver" Desc="Optional. Leave blank to auto-detect from the JAR unless SPI is ambiguous (e.g. org.apache.arrow.driver.jdbc.ArrowFlightJdbcDriver)." HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/" />
                <Param Name="DriverFilePaths" Editor="FileOpen" Label="JDBC driver file(s)" Required="True" Value="{DownloadFolder}\flight-sql-jdbc-driver-19.0.0.jar" Desc="Filled by the wizard after download. Separate multiple JARs with a semicolon (e.g. C:\ZappySys\Jdbc\MyConnector\driver.jar)." HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/" />
                <Param Name="HostName" Label="Host" Required="True" Value="MyHostName" Desc="JDBC host name or IP (e.g. MyHostName)." HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/" />
                <Param Name="Port" Label="TCP port" Required="True" Value="443" Desc="JDBC port (e.g. 443)." HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/" />
                <Param Name="token" Label="Token" Required="True" Secret="True" Desc="InfluxDB 3 API token with query access. Create it in the Influx UI or CLI." HelpLink="https://docs.influxdata.com/influxdb3/core/admin/tokens/" />
                <Param Name="database" Label="Database" Required="True" Desc="InfluxDB 3 database name to query." HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/" />
                <Param Name="useEncryption" Label="Use encryption" Required="False" Value="true" Desc="Set true for TLS (Cloud / 443). Set false only for local Core without TLS." HelpLink="https://arrow.apache.org/docs/java/flight_sql_jdbc_driver.html" />
            </Params>
            <Notes>
                <![CDATA[<p>InfluxDB 3 SQL is exposed over Arrow Flight SQL. Create an API token in the Influx console (same idea as a Stripe secret key).</p>
<ol>
  <li>Log in to your InfluxDB 3 Cloud or Core/Enterprise UI.</li>
  <li>Open <strong>API Tokens</strong> (or <code>influx auth create</code> on Core) and create a token with query permission on the database.</li>
  <li>Copy the host (no <code>https://</code>) and Flight/SQL port. Cloud often uses 443 with TLS.</li>
  <li>Paste the token into <strong>Token</strong>. Set database name to your Influx database/bucket equivalent.</li>
  <li>Do not point the Flight URL at a random redirect; this is host:port of the Flight SQL endpoint, not an OAuth callback.</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://docs.influxdata.com/influxdb3/core/query-data/sql/">
            <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[SELECT * FROM information_schema.tables]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="select-rows" Label="Select rows" HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/">
            <Desc><![CDATA[<p>Returns rows from <code>my_measurement</code>. Replace the identifier with your catalog object. Works in Excel, SSRS, and Crystal Reports.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT * FROM my_measurement]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="filter-rows" Label="Filter with WHERE" HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/">
            <Desc><![CDATA[<p>Returns matching rows from <code>my_measurement</code>. Swap the column and literal for your schema.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT * FROM my_measurement
WHERE id = 1]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="join-tables" Label="Join tables" HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/">
            <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 my_measurement 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://docs.influxdata.com/influxdb3/core/query-data/sql/">
            <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 my_measurement
GROUP BY status]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="having" Label="Filter groups with HAVING" HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/">
            <Desc><![CDATA[<p>Keeps groups whose count is at least 10.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT status, COUNT(*) AS row_count
FROM my_measurement
GROUP BY status
HAVING COUNT(*) >= 10]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="order-limit" Label="Order and limit" HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/">
            <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 my_measurement
ORDER BY id
LIMIT 100]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="count-all" Label="Count rows" HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/">
            <Desc><![CDATA[<p>Returns the number of rows in <code>my_measurement</code>.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT COUNT(*) AS row_count FROM my_measurement]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="case-expr" Label="CASE expression" HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/">
            <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 my_measurement]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="select-list" Label="Select specific columns" HelpLink="https://docs.influxdata.com/influxdb3/core/query-data/sql/">
            <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 my_measurement]]>
            </Code>
        </Example>
    </Examples>
</ApiConfig>
