使用 sqlline 查询在 Java 中创建的 Ignite 缓存
Query Ignite cache created in Java with sqlline
我正在使用 ignite 的 CacheQueryExample:
public class CacheQueryExample {
/** Organizations cache name. */
private static final String ORG_CACHE = CacheQueryExample.class.getSimpleName() + "Organizations";
/** Persons collocated with Organizations cache name. */
private static final String PERSON_CACHE = CacheQueryExample.class.getSimpleName() + "Persons";
/**
* Executes example.
*
* @param args Command line arguments, none required.
* @throws Exception If example execution failed.
*/
public static void main(String[] args) throws Exception {
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
System.out.println();
System.out.println(">>> Cache query example started.");
CacheConfiguration<Long, Organization> orgCacheCfg = new CacheConfiguration<>(ORG_CACHE);
orgCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
...
使用 sqlline 创建了以下表:
+-----------+--------------------------------+-----------------------------+------------+---------+----------+------------+-----------+---------------------------+---------------+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_CAT | TYPE_SCHEM | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATIO |
+-----------+--------------------------------+-----------------------------+------------+---------+----------+------------+-----------+---------------------------+---------------+
| IGNITE | CacheQueryExampleOrganizations | ORGANIZATION | TABLE | | | | | | |
| IGNITE | CacheQueryExamplePersons | PERSON | TABLE
如何在 sqlline 中查询这些表?我尝试了以下并且 none 有效:
0: jdbc:ignite:thin://127.0.0.1:10800> select * from person;
Error: Failed to parse query. Table "PERSON" not found; SQL statement:
select * from person [42102-197] (state=42000,code=1001)
0: jdbc:ignite:thin://127.0.0.1:10800> select * from CacheQueryExamplePersons.person;
Error: Failed to parse query. Schema "CACHEQUERYEXAMPLEPERSONS" not found; SQL statement:
select * from CacheQueryExamplePersons.person [90079-197] (state=42000,code=1001)
并记录到特定模式的 sqlline:
0: jdbc:ignite:thin://127.0.0.1:10800/CacheQu> select * from person;
Error: Failed to set schema for DB connection for thread [schema=CACHEQUERYEXAMPLEPERSONS] (state=50000,code=1)
尝试用双引号将 table 方案名称括起来。
我正在使用 ignite 的 CacheQueryExample:
public class CacheQueryExample {
/** Organizations cache name. */
private static final String ORG_CACHE = CacheQueryExample.class.getSimpleName() + "Organizations";
/** Persons collocated with Organizations cache name. */
private static final String PERSON_CACHE = CacheQueryExample.class.getSimpleName() + "Persons";
/**
* Executes example.
*
* @param args Command line arguments, none required.
* @throws Exception If example execution failed.
*/
public static void main(String[] args) throws Exception {
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
System.out.println();
System.out.println(">>> Cache query example started.");
CacheConfiguration<Long, Organization> orgCacheCfg = new CacheConfiguration<>(ORG_CACHE);
orgCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
...
使用 sqlline 创建了以下表:
+-----------+--------------------------------+-----------------------------+------------+---------+----------+------------+-----------+---------------------------+---------------+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_CAT | TYPE_SCHEM | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATIO |
+-----------+--------------------------------+-----------------------------+------------+---------+----------+------------+-----------+---------------------------+---------------+
| IGNITE | CacheQueryExampleOrganizations | ORGANIZATION | TABLE | | | | | | |
| IGNITE | CacheQueryExamplePersons | PERSON | TABLE
如何在 sqlline 中查询这些表?我尝试了以下并且 none 有效:
0: jdbc:ignite:thin://127.0.0.1:10800> select * from person;
Error: Failed to parse query. Table "PERSON" not found; SQL statement:
select * from person [42102-197] (state=42000,code=1001)
0: jdbc:ignite:thin://127.0.0.1:10800> select * from CacheQueryExamplePersons.person;
Error: Failed to parse query. Schema "CACHEQUERYEXAMPLEPERSONS" not found; SQL statement:
select * from CacheQueryExamplePersons.person [90079-197] (state=42000,code=1001)
并记录到特定模式的 sqlline:
0: jdbc:ignite:thin://127.0.0.1:10800/CacheQu> select * from person;
Error: Failed to set schema for DB connection for thread [schema=CACHEQUERYEXAMPLEPERSONS] (state=50000,code=1)
尝试用双引号将 table 方案名称括起来。