iartiukhov commented on code in PR #7103:
URL: https://github.com/apache/ignite-3/pull/7103#discussion_r2588412869


##########
examples/java/src/main/java/org/apache/ignite/example/table/MapperExample.java:
##########
@@ -17,6 +17,10 @@
 
 package org.apache.ignite.example.table;
 
+import static java.sql.DriverManager.getConnection;

Review Comment:
   Let's avoid static imports and use `DriverManager.getConnection()` instead.



##########
examples/java/src/main/java/org/apache/ignite/example/table/MapperExample.java:
##########
@@ -37,6 +41,29 @@ public Integer toColumnType(String cityId) {
     }
 
     public static void main(String[] args) throws Exception {
+
+        try (
+                Connection conn = 
getConnection("jdbc:ignite:thin://127.0.0.1:10800/");
+                Statement stmt = conn.createStatement()
+        ) {
+
+            stmt.executeUpdate("DROP TABLE IF EXISTS Person");
+
+            stmt.executeUpdate(
+                    "CREATE TABLE IF NOT EXISTS Person ("
+                            + "id int primary key, "
+                            + "city varchar, "
+                            + "name varchar, "
+                            + "age int, "
+                            + "company varchar, "
+                            + "city_id int)"
+            );
+
+            stmt.executeUpdate(
+                    "INSERT INTO Person (id, city, name, age, company, 
city_id) VALUES (1, 'London', 'John Doe', 42, 'Apache', 101)");
+            stmt.executeUpdate(
+                    " INSERT INTO Person (id, city, name, age, company, 
city_id) VALUES (2, 'New York', 'Jane Doe', 36, 'Apache', 102)");

Review Comment:
   An extra space.



##########
examples/java/src/main/java/org/apache/ignite/example/table/MapperExample.java:
##########
@@ -50,10 +77,21 @@ public static void main(String[] args) throws Exception {
                     .table("person")
                     .recordView(mapper);
 
-
             Person myPerson = new Person(2, "2", "John Doe", 40, "Apache");
 
             view.upsert(null, myPerson);
+        } finally {
+
+            System.out.println("Dropping the table...");
+        }
+        try (
+                Connection conn = 
getConnection("jdbc:ignite:thin://127.0.0.1:10800/");

Review Comment:
   Let's use single Connection object. I.e. move them to the upper `try-catch` 
block like it is done in `SqlJdbcExample.java`.



-- 
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]

Reply via email to