Database System Plugins
In this document, we show how to build custom connectors to any relational/non-relational database management system. These connectors interface Sclera with an arbitrary database system, relational or non-relational, providing access to the underlying data, and also enable Sclera to push down computations in relevant parts user queries and commands on the interfaced database system.
Sclera - Oracle Connector, Sclera - MySQL Connector, and Sclera - PostgreSQL Connector are built using this SDK. For examples of how these connectors are used in Sclera, please refer to the documentation on connecting Sclera to database systems.
Building Database System Connectors◄
To build a custom datasource connector, you need to provide implementations of the following abstract classes in the SDK:
-
DBService
(API Link)- Provides the database system as a service to Sclera.
- Contains an
id
that identifies this service. - Contains a method
createLocation
that is used to create a new location instance for this service.
-
Location
(API Link)- Represents the underlying database system.
- Provides the configuration parameters, and properties (e.g. temporary or persistent, read-only or read-write, etc.).
- Provides the driver for interfacing with the underlying system.
-
StatementDriver
(API Link)- Executes the statements provided by Sclera on the underlying database system, and passes back the results.
- Provides the metadata driver for accessing the metadata for the data stored in the underlying database system.
-
StatementMetadataDriver
(API Link)- Provides the metadata for the data stored in the underlying database system.
Special case: Relational Databases◄
If the underlying system is a relational database system, which talks SQL and uses JDBC as the interface, Sclera does most of the work. For such systems, you need to provide implementations of the following:
-
DBService
(API Link)- Provides the relational database system as a service to Sclera.
-
RdbmsLocation
(API LInk)- Represents the underlying relational database system.
- Provides a standard implementation of
StatementDriver
andStatementMetadataDriver
, based on JDBC. You only need to configure the JDBC configuration parameters (e.g. the JDBC URL) for the underlying system, and additional location properties (e.g. temporary or persistent, read-only or read-write, etc.). - Provides the SQL mapper for translating Sclera's internal SQL representation to the SQL for the underlying system.
-
SqlMapper
(API LInk)- Translates Sclera's internal SQL representation to the SQL for the underlying system. This is needed because the SQL clauses and constructs across different systems vary significantly and sometimes do not follow the standard.
The Sclera - MySQL Connector, included with the Sclera platform, is open source and implements the relational database interface mentioned above.
Packaging and Deploying the Connector◄
The included Sclera - MySQL Connector implementation uses sbt for building the connector (installation details). This is not a requirement -- any other build tool can be used instead.
Dependencies◄
The implementation has a dependency on:
- the database system's driver (e.g. the appropriate JDBC driver for relational database systems).
- the
"sclera-core"
and"sclera-config"
core components. Note that these dependencies is annotated"provided"
since these libraries will already be available in theCLASSPATH
when this connector is run with Sclera. - (optional) the test framework
scalatest
for running the tests.
These are specified in the build file. As an example, see the Sclera - MySQL Connector's build file.
Deployment Steps◄
Follow steps similar to those described here.
Note: Please ensure that the identifier you assign to the connector is unique, that is - does not conflict with the identifier of any other available DBService
instance.