Ivan,

You can refer to this example:
https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
 
<https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java>

Also there is a plenty of other useful examples available under the examples 
directory of an Apache Ignite distribution. Just fish in it.

—
Denis

> On Mar 16, 2017, at 4:25 PM, Ivan Zeng <[email protected]> wrote:
> 
> Hi Denis,
> 
> Thanks for the response.  Is there any sample code on how to use the
> IgniteCache to create caches with different fields and load data into
> the cache?
> 
> Thanks so much.
> Ivan
> 
> On Thu, Mar 16, 2017 at 3:52 PM, Denis Magda <[email protected]> wrote:
>> Hi Ivan,
>> 
>> Yes, caches can be created dynamically:
>> https://apacheignite.readme.io/docs/jcache#section-dynamic-cache
>> 
>> —
>> Denis
>> 
>> On Mar 16, 2017, at 3:28 PM, Ivan Zeng <[email protected]> wrote:
>> 
>> Hi Dmitriy,
>> 
>> Thanks for your reply.  I was able to load data into cache after
>> adding the QueryEntity in configuration. And I actually needed to
>> restart the server database to pick up the new configuration.  Is
>> there a way that I can create new cache without restarting the server?
>> 
>> Thank so much
>> Ivan
>> 
>> On Thu, Mar 16, 2017 at 1:24 PM, Dmitriy Setrakyan
>> <[email protected]> wrote:
>> 
>> DDL commands are not supported in Ignite yet. However, in Ignite the table
>> will be created automatically if you define a class with @SqlQueryField
>> annotations or define a QueryEntity in configuration, as described here:
>> 
>> https://apacheignite.readme.io/docs/indexes
>> 
>> Starting with Ignite 2.0, planned in April, Ignite will support CREATE/DROP
>> INDEX command. Further it is planned that towards June/July Ignite will have
>> full DDL support, including CREATE/ALTER/DROP TABLE commands.
>> 
>> D.
>> 
>> On Thu, Mar 16, 2017 at 11:46 AM, Ivan Zeng <[email protected]> wrote:
>> 
>> 
>> Hi,
>> 
>> I am new to Ignite.  Could you tell me the right way to create a
>> cache, load data into cache, and then query the cache via JDBC?
>> 
>> I wrote the following code to create a table via JDBC.
>> 
>> 
>>   Class.forName("org.apache.ignite.IgniteJdbcDriver");
>>   con = DriverManager.getConnection (connectionURL)
>>   String create_sql = "CREATE TABLE Person " +
>>                 "(_key INTEGER PRIMARY KEY, " +
>>                 " name VARCHAR(255), " +
>>                 " age INTEGER);";
>>   Statement cstmt = con.createStatement();
>>   cstmt.executeQuery(create_sql);
>> 
>> 
>> But i got this error.
>> 
>> java.sql.SQLException: Failed to query Ignite.
>> at
>> org.apache.ignite.internal.jdbc2.JdbcStatement.executeQuery(JdbcStatement.java:131)
>> at IgniteJDBC.main(IgniteJDBC.java:26)
>> Caused by: javax.cache.CacheException: Unsupported SQL statement:
>> CREATE TABLE Person (_key INTEGER PRIMARY KEY,  name VARCHAR(255),
>> age INTEGER)
>> 
>> Thanks so much
>> Ivan
>> 
>> 
>> 
>> 

Reply via email to