create table via JDBC

classic Classic list List threaded Threaded
8 messages Options
Ivan Zeng Ivan Zeng
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

create table via JDBC

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
dsetrakyan dsetrakyan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: create table via JDBC

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:


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 <[hidden email]> 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

Ivan Zeng Ivan Zeng
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: create table via JDBC

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
<[hidden email]> 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 <[hidden email]> 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
>
>
Denis Magda-2 Denis Magda-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: create table via JDBC

Hi Ivan,

Yes, caches can be created dynamically:

Denis

On Mar 16, 2017, at 3:28 PM, Ivan Zeng <[hidden email]> 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
<[hidden email]> 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 <[hidden email]> 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



Ivan Zeng Ivan Zeng
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: create table via JDBC

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 <[hidden email]> 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 <[hidden email]> 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
> <[hidden email]> 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 <[hidden email]> 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
>
>
>
>
Denis Magda-2 Denis Magda-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: create table via JDBC

Ivan,

You can refer to this example:

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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
<[hidden email]> 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 <[hidden email]> 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





Ivan Zeng Ivan Zeng
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: create table via JDBC

Thanks Denis.

I see that the example you gave use existing classes.  These classes
will need to be defined ahead of time.

I will dig into the example directory to see if I can find example
where a cache is created and then fields are added dynamically.

If you know of any of this example, please let me know.  Thank you so much.

Ivan

On Thu, Mar 16, 2017 at 4:47 PM, Denis Magda <[hidden email]> wrote:

> 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
>
> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
> <[hidden email]> 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 <[hidden email]> 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
>
>
>
>
>
Denis Magda-2 Denis Magda-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: create table via JDBC

I will dig into the example directory to see if I can find example
where a cache is created and then fields are added dynamically.

It will be feasible to add new QueryEntity fields and indexes in a month or so once this ticket is completed:
https://issues.apache.org/jira/browse/IGNITE-4565

For now you can define them only statically.

However, the lack of this feature doesn’t prevent you from putting objects into a cache with new objects' fields. You just won’t be able to query over these new fields using SQL queries until IGNITE-4565 gets merged.

Denis

On Mar 16, 2017, at 5:28 PM, Ivan Zeng <[hidden email]> wrote:

Thanks Denis.

I see that the example you gave use existing classes.  These classes
will need to be defined ahead of time.

I will dig into the example directory to see if I can find example
where a cache is created and then fields are added dynamically.

If you know of any of this example, please let me know.  Thank you so much.

Ivan

On Thu, Mar 16, 2017 at 4:47 PM, Denis Magda <[hidden email]> wrote:
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

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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
<[hidden email]> 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 <[hidden email]> 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






Loading...