Executes SQL and returns an SqlResult. Converts passed SQL string and parameter values into an SqlStatement object and invokes executeStatement.
SQL string. SQL string placeholder character is question mark(?
)
Parameter list. The parameter count must be equal to number of placeholders in the SQL string
Options that are affecting how the query is executed
Executes SQL and returns an SqlResult.
SQL statement object
Generated using TypeDoc
SQL Service of the client. You can use this service to execute SQL queries.
Enabling SQL Service
To use this service, the Jet engine must be enabled on the members and the
hazelcast-sql
module must be in the classpath of the members. If you are using the CLI, Docker image, or distributions to start Hazelcast members, then you don't need to do anything, as the above preconditions are already satisfied for such members.However, if you are using Hazelcast members in the embedded mode, or receiving errors saying that
The Jet engine is disabled
orCannot execute SQL query because "hazelcast-sql" module is not in the classpath.
while executing queries, enable the Jet engine following one of the instructions pointed out in the error message, or add thehazelcast-sql
module to your member's classpath.Overview
Hazelcast is currently able to execute distributed SQL queries using the following connectors:
SQL statements are not atomic. INSERT/SINK can fail and commit part of the data.
Usage
Before you can access any object using SQL, a mapping has to be created. See the documentation for the
CREATE MAPPING
command.When a query is executed, an SqlResult is returned. The returned result is an async iterable of SqlRowType. It can also be iterated using SqlResult.next method. The result should be closed at the end to release server resources. Fetching the last page closes the result. The code snippet below demonstrates a typical usage pattern: