Hi Amir,
I tried the following java code, and it was successful.
PreparedStatement stmt = conn.prepareStatement("INSERT INTO
\"igniteCache\".STRING(_key, _val) VALUES(?, ?)");
stmt.setString(1,"keyInsert");
stmt.setString(2,"ValueInsert");
stmt.execute();
I do not know if this is the best way to achieve it or not.
Thanks
Rick
From: [email protected] [mailto:[email protected]]
Sent: Friday, March 23, 2018 2:31 PM
To: [email protected]
Subject: RE: Get all data of one cache in Ignite without creating a new ignite
node
Hi Amir
By the way,
if we would like to insert/update data to cache, do you have any idea to
achieve this?
PreparedStatement stmt = conn.prepareStatement("INSERT INTO
\"igniteCache\".STRING");
stmt.setString(1, "keyInsert");
stmt.setString(2, "valueInsert");
stmt.execute();
Error: InvocationTargetException: Failed to parse query. Syntax error in SQL
statement "INSERT INTO ""igniteCache"".STRING[*]"; expected "(, DIRECT, SORTED,
DEFAULT, VALUES, SET, (, WITH, SELECT, FROM"; SQL statement:
Rick
From: 林良憲
Sent: Friday, March 23, 2018 1:59 PM
To: [email protected]<mailto:[email protected]>
Subject: RE: Get all data of one cache in Ignite without creating a new ignite
node
Hi Amir
I use the method recommended by you, and that works well.
My testing code is as:
ResultSet rs = conn.createStatement().executeQuery("select * from
\"igniteCache\".STRING");
while (rs.next()) {
String key = rs.getNString(1);
String value = rs.getString(2);
System.out.println("cacheData for 'key': " + key);
System.out.println("cacheData for 'value': " + value);
}
Thank for your help
Rick
From: Amir Akhmedov [mailto:[email protected]]
Sent: Friday, March 23, 2018 12:09 AM
To: [email protected]<mailto:[email protected]>
Subject: Re: Get all data of one cache in Ignite without creating a new ignite
node
Hi Rick,
In Ignite cache name is used as a database schema and a cache value type as a
table name. So, in your case you should execute
select * from "igniteCache".STRING to get your cache data.
I would recomend you to run your Ignite instance with
-DIGNITE_H2_DEBUG_CONSOLE=true parameter so you could see how tables look like
in your cluster
Thanks,
Amir
On Thu, Mar 22, 2018, 3:41 AM <[email protected]<mailto:[email protected]>>
wrote:
Hi Andrey,
I tried to use JDBC client at
https://apacheignite-sql.readme.io/docs/jdbc-driver
The java code is as:
Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
Connection conn =
DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1<http://127.0.0.1>");
ResultSet rs = conn.createStatement().executeQuery("select * from igniteCache");
There is a problem, as: InvocationTargetException: Failed to parse query. Table
"IGNITECACHE" not found; SQL statement:
I do not know how to set the rs. I think that "IGNITECACHE" is the default
Table.
So, how to set the igniteCache as a table?
Rick
From: Andrey Mashenkov
[mailto:[email protected]<mailto:[email protected]>]
Sent: Thursday, March 22, 2018 3:01 PM
To: [email protected]<mailto:[email protected]>
Subject: Re: Get all data of one cache in Ignite without creating a new ignite
node
Rick,
Yes, you have to start a node to get access to the grid from another JVM,
Or use REST, or JDBC client.
чт, 22 марта 2018, 9:49 Pavel Vinokurov
<[email protected]<mailto:[email protected]>>:
Hi Rick,
You could use rest api that documented in
https://apacheignite.readme.io/docs/rest-api .
Thanks,
Pavel
2018-03-22 9:44 GMT+03:00 <[email protected]<mailto:[email protected]>>:
Dear all,
My settings of running environment is as:
OS: Ubuntn 14.04.3 LTS
JAVA: JDK 1.7
Ignite: 2.4.0
I would like to get all data of one cache in Ignite
Without creating a new ignite node, I do not know how to get data by another
executive java program (without the Ignition.getOrStart(cfg)).
The setting of one listening ignite node is:
" IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setClientMode(false); //server
CacheConfiguration cacheConf = new CacheConfiguration();
cacheConf.setName("igniteCache");
cacheConf.setIndexedTypes(String.class, String.class);
cacheConf.setCacheMode(CacheMode.REPLICATED);
cacheConf.setAtomicityMode(CacheAtomicityMode.ATOMIC);
cfg.setCacheConfiguration(cacheConf);
Ignite igniteNode =
IgniteCache cache = igniteNode.getOrCreateCache(cacheConf);
int datasize = 10;
for (int i = 0; i < datasize; i++) {
cache.put("key " + Integer.toString(i), Integer.toString(i));
}"
In the Ignite document, there are many ways to get data. However, it seems to
need to create a new ignite node (server/client) to get data.
I know that Restful API is a way to get data. But, it is not flexible to use
over the java program.
If you have any idea about the issue, I am looking forward to hearing from you.
Thanks
Rick
--
本信件可能包含工研院機密資訊,非指定之收件者,請勿使用或揭露本信件內容,並請銷毀此信件。 This email may contain
confidential information. Please do not use or disclose it in any way and
delete it if you are not the intended recipient.
--
Regards
Pavel Vinokurov
--
本信件可能包含工研院機密資訊,非指定之收件者,請勿使用或揭露本信件內容,並請銷毀此信件。 This email may contain
confidential information. Please do not use or disclose it in any way and
delete it if you are not the intended recipient.
--
本信件可能包含工研院機密資訊,非指定之收件者,請勿使用或揭露本信件內容,並請銷毀此信件。 This email may contain
confidential information. Please do not use or disclose it in any way and
delete it if you are not the intended recipient.
--
本信件可能包含工研院機密資訊,非指定之收件者,請勿使用或揭露本信件內容,並請銷毀此信件。 This email may contain
confidential information. Please do not use or disclose it in any way and
delete it if you are not the intended recipient.