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
AffinityKeyjavadoc 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/libsfolder.Configuration
JDBC connection URL has the following pattern:
jdbc:ignite:thin://<hostname>:<port>/
Note the following:- Hostname is required.
- If port is not defined,
10800is used (default for Ignite thin client).
Propertiesobject 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 booleanacceptsURL(String url)Connectionconnect(String url, Properties props)intgetMajorVersion()intgetMinorVersion()LoggergetParentLogger()DriverPropertyInfo[]getPropertyInfo(String url, Properties info)booleanjdbcCompliant()static Driverregister()
-
-
-
Method Detail
-
connect
public Connection connect(String url, Properties props) throws SQLException
- Specified by:
connectin interfaceDriver- Throws:
SQLException
-
acceptsURL
public boolean acceptsURL(String url) throws SQLException
- Specified by:
acceptsURLin interfaceDriver- Throws:
SQLException
-
getPropertyInfo
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
- Specified by:
getPropertyInfoin interfaceDriver- Throws:
SQLException
-
getMajorVersion
public int getMajorVersion()
- Specified by:
getMajorVersionin interfaceDriver
-
getMinorVersion
public int getMinorVersion()
- Specified by:
getMinorVersionin interfaceDriver
-
jdbcCompliant
public boolean jdbcCompliant()
- Specified by:
jdbcCompliantin interfaceDriver
-
getParentLogger
public Logger getParentLogger() throws SQLFeatureNotSupportedException
- Specified by:
getParentLoggerin interfaceDriver- Throws:
SQLFeatureNotSupportedException
-
register
public static Driver register()
- Returns:
- Driver instance.
-
-