Avatica is a framework for building JDBC and ODBC drivers for databases, and an RPC wire protocol.
Avatica's Java binding has very few dependencies. Even though it is part of Apache Calcite it does not depend on other parts of Calcite. It depends only on JDK 8+ and Jackson.
Avatica's wire protocols are JSON or Protocol Buffers over HTTP. The Java implementation of the JSON protocol uses Jackson to convert request/response command objects to/from JSON.
Avatica-Server is a Java implementation of Avatica RPC.
Core concepts:
Meta
Meta
in terms of request and response command objectsAvatica implements JDBC by means of [AvaticaFactory]({{ site.apiRoot }}/org/apache/calcite/avatica/AvaticaFactory.html). An implementation of AvaticaFactory
creates implementations of the JDBC classes ([Driver]({{ site.jdkApiRoot }}/java/sql/Driver.html), [Connection]({{ site.jdkApiRoot }}/java/sql/Connection.html), [Statement]({{ site.jdkApiRoot }}/java/sql/Statement.html), [ResultSet]({{ site.jdkApiRoot }}/java/sql/ResultSet.html)) on top of a Meta
.
Work has not started on Avatica ODBC.
Avatica ODBC would use the same wire protocol and could use the same server implementation in Java. The ODBC client would be written in C or C++.
Since the Avatica protocol abstracts many of the differences between providers, the same ODBC client could be used for different databases.
Although the Avatica project does not include an ODBC driver, there are ODBC drivers written on top of the Avatica protocol, for example an ODBC driver for Apache Phoenix.
Avatica-server embeds the Jetty HTTP server, providing a class [HttpServer]({{ site.apiRoot }}/org/apache/calcite/avatica/server/HttpServer.html) that implements the Avatica RPC protocol and can be run as a standalone Java application.
Connectors in HTTP server can be configured if needed by extending HttpServer
class and overriding its configureConnector()
method. For example, user can set requestHeaderSize
to 64K bytes as follows:
{% highlight java %} HttpServer server = new HttpServer(handler) { @Override protected ServerConnector configureConnector( ServerConnector connector, int port) { HttpConnectionFactory factory = (HttpConnectionFactory) connector.getDefaultConnectionFactory(); factory.getHttpConfiguration().setRequestHeaderSize(64 << 10); return super.configureConnector(connector, port); } }; server.start(); {% endhighlight %}
We know that it is important that client libraries have minimal dependencies.
Avatica is a sub-project of Apache Calcite, maintained in a separate repository. It does not depend upon any other part of Calcite.
Packages:
The following is a list of available Avatica clients. Several describe themselves as adapters for Apache Phoenix but also work with other Avatica back-ends. Contributions for clients in other languages are highly welcomed!