ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gunman524 <guojin0...@126.com>
Subject Can JAVA API SqlQuery query a cache create by SQL DDL?
Date Wed, 15 Nov 2017 05:44:14 GMT
Hi guys,

I use JDBC client driver to create a table,like:

stmt.executeUpdate("CREATE TABLE IF NOT EXISTS person ( id int,orgId LONG,
name VARCHAR, salary LONG ,PRIMARY KEY (id)) WITH \"backups=1,
affinityKey=id\"");

Could I use SqlQuery API to query this cache? I tried this way but does not
work

IgniteCache<Object, Person> cache =
ignite.cache("SQL_PUBLIC_PERSON").withKeepBinary();
        SqlQuery sql = new SqlQuery("SQL_PUBLIC_PERSON","id >? and id <?");

        try (QueryCursor<Map.Entry&lt;Object, BinaryObject>> cursor =
cache.query(sql.setArgs(5,10))) {
            for (Map.Entry<Object, BinaryObject> e : cursor)
                System.out.println(e.getValue().toString());
        }

Thanks



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Mime
View raw message