Package org.apache.ignite
Class IgniteJdbcThinDriver
- java.lang.Object
-
- org.apache.ignite.IgniteJdbcThinDriver
-
- All Implemented Interfaces:
Driver
public class IgniteJdbcThinDriver extends Object implements Driver
JDBC driver thin implementation for In-Memory Data Grid.Driver allows to get distributed data from Ignite cache using standard SQL queries and standard JDBC API. It will automatically get only fields that you actually need from objects stored in cache.
Limitations
Data in Ignite cache is usually distributed across several nodes, so some queries may not work as expected since the query will be sent to each individual node and results will then be collected and returned as JDBC result set. Keep in mind following limitations (not applied if data is queried from one node only, or data is fully co-located or fully replicated on multiple nodes):-
Joins will work correctly only if joined objects are stored in
collocated mode. Refer to
AffinityKey
javadoc for more details. - Note that if you are connected to local or replicated cache, all data will be queried only on one node, not depending on what caches participate in the query (some data from partitioned cache can be lost). And visa versa, if you are connected to partitioned cache, data from replicated caches will be duplicated.
SQL Notice
Driver allows to query data from several caches. Cache that driver is connected to is treated as default schema in this case. Other caches can be referenced by their names.\Dependencies
JDBC driver is located in main Ignite JAR inIGNITE_HOME/libs
folder.Configuration
JDBC connection URL has the following pattern:
jdbc:ignite:thin://<hostname>:<port>/
Note the following:- Hostname is required.
- If port is not defined,
10800
is used (default for Ignite thin client).
Properties
object passed toDriverManager.getConnection(String, Properties)
method:Name Description Default Optional ignite.jdbc.distributedJoins Flag to enable distributed joins. false
(distributed joins are disabled)Yes ignite.jdbc.enforceJoinOrder Flag to enforce join order of tables in the query. false
(enforcing join order is disabled)Yes Example
// Open JDBC connection. Connection conn = DriverManager.getConnection("jdbc:ignite:thin//localhost:10800"); // Query persons' names ResultSet rs = conn.createStatement().executeQuery("select name from Person"); while (rs.next()) { String name = rs.getString(1); ... } // Query persons with specific age PreparedStatement stmt = conn.prepareStatement("select name, age from Person where age = ?"); stmt.setInt(1, 30); ResultSet rs = stmt.executeQuery(); while (rs.next()) { String name = rs.getString("name"); int age = rs.getInt("age"); ... }
-
-
Constructor Summary
Constructors Constructor Description IgniteJdbcThinDriver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptsURL(String url)
Connection
connect(String url, Properties props)
int
getMajorVersion()
int
getMinorVersion()
Logger
getParentLogger()
DriverPropertyInfo[]
getPropertyInfo(String url, Properties info)
boolean
jdbcCompliant()
static Driver
register()
-
-
-
Method Detail
-
connect
public Connection connect(String url, Properties props) throws SQLException
- Specified by:
connect
in interfaceDriver
- Throws:
SQLException
-
acceptsURL
public boolean acceptsURL(String url) throws SQLException
- Specified by:
acceptsURL
in interfaceDriver
- Throws:
SQLException
-
getPropertyInfo
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
- Specified by:
getPropertyInfo
in interfaceDriver
- Throws:
SQLException
-
getMajorVersion
public int getMajorVersion()
- Specified by:
getMajorVersion
in interfaceDriver
-
getMinorVersion
public int getMinorVersion()
- Specified by:
getMinorVersion
in interfaceDriver
-
jdbcCompliant
public boolean jdbcCompliant()
- Specified by:
jdbcCompliant
in interfaceDriver
-
getParentLogger
public Logger getParentLogger() throws SQLFeatureNotSupportedException
- Specified by:
getParentLogger
in interfaceDriver
- Throws:
SQLFeatureNotSupportedException
-
register
public static Driver register()
- Returns:
- Driver instance.
-
-