valepakh commented on code in PR #7738:
URL: https://github.com/apache/ignite-3/pull/7738#discussion_r2917348576
##########
examples/java/build.gradle:
##########
@@ -34,6 +34,8 @@ tasks.register('deploymentUnitJar', Jar) {
from(sourceSets.main.output.classesDirs) {
include 'org/apache/ignite/example/**/*Job.class'
include 'org/apache/ignite/example/**/*Job$*.class'
+ include 'org/apache/ignite/example/**/*Receiver.class'
+ include 'org/apache/ignite/example/**/*Receiver$*.class'
Review Comment:
This also looks like a separate issue
##########
examples/java/src/main/java/org/apache/ignite/example/table/TableExample.java:
##########
@@ -43,52 +43,58 @@ public static void main(String[] args) throws Exception {
.addresses("127.0.0.1:10800")
.build()
) {
- // Create a table to work with later
- client.sql().execute("CREATE TABLE IF NOT EXISTS Person (" +
- "id int primary key," +
- "city_id int," +
- "name varchar," +
- "age int," +
- "company varchar)"
- );
-
// Get the tables API to interact with database tables
IgniteTables tableApi = client.tables();
- // Retrieve a list of all existing tables in the cluster
- //List<Table> existingTables = tableApi.tables();
-
- // Get the first table from the list (for demonstration purposes)
- //Table firstTable = existingTables.get(0);
-
- // Access a specific table by its simple name
- //Table specificTable = tableApi.table("MY_TABLE");
-
// Create a qualified table name by parsing a string (schema.table
format)
QualifiedName qualifiedTableName =
QualifiedName.parse("PUBLIC.Person");
// Alternative way to create qualified name using schema and table
parts
//QualifiedName qualifiedTableName = QualifiedName.of("PUBLIC",
"MY_TABLE");
- // Access a table using the qualified name (includes schema)
- Table myTable = tableApi.table(qualifiedTableName);
+ try {
+ // Create a table to work with later
+ client.sql().execute("CREATE TABLE Person (" +
+ "id int primary key," +
+ "city_id int," +
+ "name varchar," +
+ "age int," +
+ "company varchar)"
+ );
+
+ // Retrieve a list of all existing tables in the cluster
+ //List<Table> existingTables = tableApi.tables();
+
+ // Get the first table from the list (for demonstration
purposes)
+ //Table firstTable = existingTables.get(0);
+
+ // Access a specific table by its simple name
+ //Table specificTable = tableApi.table("MY_TABLE");
+
+ // Access a table using the qualified name (includes schema)
+ Table myTable = tableApi.table(qualifiedTableName);
+
+ RecordView<Tuple> personTableView = myTable.recordView();
- RecordView<Tuple> personTableView = myTable.recordView();
+ Tuple personTuple = Tuple.create()
+ .set("id", 1)
+ .set("city_id", 3)
+ .set("name", "John Doe")
+ .set("age", 32)
+ .set("company", "Apache");
- Tuple personTuple = Tuple.create()
- .set("id", 1)
- .set("city_id", 3)
- .set("name", "John Doe")
- .set("age", 32)
- .set("company", "Apache");
+ personTableView.upsert(null, personTuple);
- personTableView.upsert(null, personTuple);
+ Tuple personIdTuple = Tuple.create()
+ .set("id", 1);
+ Tuple insertedPerson = personTableView.get(null,
personIdTuple);
- Tuple personIdTuple = Tuple.create()
- .set("id", 1);
- Tuple insertedPerson = personTableView.get(null, personIdTuple);
+ System.out.println("Person name: " +
insertedPerson.stringValue("name"));
+ } finally {
+ System.out.println("\nDropping the table...");
Review Comment:
```suggestion
System.out.println("Dropping the table...");
```
##########
examples/java/src/main/java/org/apache/ignite/example/table/MapperExample.java:
##########
@@ -43,20 +47,25 @@ public static void main(String[] args) throws Exception {
.build()
) {
try {
- client.sql().executeScript(
- "CREATE TABLE Person ("
- + "id int primary key, "
- + "city varchar, "
- + "name varchar, "
- + "age int, "
- + "company varchar, "
- + "city_id int)"
- );
+ try (
+ Connection conn =
getConnection("jdbc:ignite:thin://127.0.0.1:10800/");
Review Comment:
What's the point of using JDBC if we have a client connection?
##########
examples/java/src/main/java/org/apache/ignite/example/table/MapperExample.java:
##########
@@ -71,12 +80,9 @@ public static void main(String[] args) throws Exception {
view.upsert(null, myPerson);
} finally {
+ System.out.println("\nDropping the table...");
Review Comment:
```suggestion
System.out.println("Dropping the table...");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]