Introduction to the Aerospike JDBC driver
Tags: aeropsike, java, sql, jdbc
Published: 2020-05-25 15:36:23

# Introduction
Once upon a time when all databases were relational and supported SQL, Java programmers (almost) did not care about the database type they were going to use. This was achieved by using JDBC drivers - software that talks to the specific database exposing standard API to the application layer.

The world has changed after the invention of NoSQL databases. These databases have some advantages comparing to the traditional relational databases but they do not have common interface. Therefore, using them requires writing specific application code for each database.

[Aerospike](https://www.aerospike.com/) is a popular, fast, mature NoSQL database. It provides client libraries for different systems and languages including Java. These libraries help to implement applications that use Aerospike DB. However, application code which uses this library has to be specific for Aerospike. 

The [Aerospike JDBC Driver](https://github.com/alexradzin/aerospike-jdbc-driver/) enables users to connect with Aerospike DB directly from any application that supports standard JDBC connectivity. 

#Key features
This is a JDBC driver. It can be used by any JDBC complaint application, e.g. UI, monitoring, querying and other general purpose tools. It supports standard SQL statements and functions and can be used by developers, QA, data analysts and DevOps engineers. It can help if somebody wants to migrate his application from relational DB to Aerospike.

This article will briefly enumerate the key features of the driver. The next articles of this series will explain particular features in depth.

#SQL compliance
##DDL
CREATE INDEX
DROP INDEX

## DML
- `INSERT`
- `SELECT`
- `UPDATE`
- `DELETE`

`WHERE` - using PK or any other column and the combination of them including calculations, parentheses etc.
`JOIN`,  LEFT JOIN`
`GROUP BY`

#Data types
The driver supports all basic Aerospike types (integer, string, bytes, 
double) mapping them to JDBC types (`INTEGER`, `VARCHAR`, `BLOB`, `DOUBLE`) respectively and corresponding java types (`int`, `String`, `byte[]`, `double`). Aerospike lists and maps are supported as well. They are mapped to the JDBC `java.sql.Array` and java.util.Map respectively. 

Additionally driver can store and retrieve java objects using either standard java serialization mechanism (for `Serializable` or `Externalizable` classes) or using custom serialization/deserialization) enabled by [user defined functions](#userdefined-functions).

#Expressions and functions
Mathematical expressions can be used in the queries:

```
select first_name, last_name, year()-year_of_birth as age from people
```

## Built-in Functions
- aggregation functions: `count()`, `max()`, `min()`, `sum()`, `avg()`
- string functions: `str()`, `concat()`, `ucase()`, `lcase()`, `len()`, reverse() etc.
- date/time functions: `now()`, `year()`, `month()`, `day()` etc.

## User-defined functions
The driver provides a lot of built-in functions. Moreover, it can be easily extended. User can implement his own functions in Java and register them via JDBC connection parameters.

#Project home
The project is available in [GitHub](https://github.com/alexradzin/aerospike-jdbc-driver/).

#What's next
Next [article](https://dev.to/alexradzin/aerospike-jdbc-driver-sql-ddl-compliance-23bc) of this series will explain the SQL compliance of the driver.