ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [3/3] incubator-ignite git commit: # IGNITE-330 Reworked example to not use external script.
Date Sun, 22 Mar 2015 11:07:41 GMT
# IGNITE-330 Reworked example to not use external script.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2f32b7ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2f32b7ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2f32b7ed

Branch: refs/heads/ignite-45
Commit: 2f32b7ed68bac65f2748631bc1e41088a8fbf6ca
Parents: 6ff0792
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Sun Mar 22 18:07:41 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Sun Mar 22 18:07:41 2015 +0700

----------------------------------------------------------------------
 .../schema-import/bin/example-database.script   | 37 --------------------
 .../store/jdbc/CacheJdbcPojoPersonStore.java    | 22 ++++++------
 2 files changed, 11 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f32b7ed/examples/schema-import/bin/example-database.script
----------------------------------------------------------------------
diff --git a/examples/schema-import/bin/example-database.script b/examples/schema-import/bin/example-database.script
deleted file mode 100644
index 8305127..0000000
--- a/examples/schema-import/bin/example-database.script
+++ /dev/null
@@ -1,37 +0,0 @@
---  Licensed to the Apache Software Foundation (ASF) under one or more
---  contributor license agreements.  See the NOTICE file distributed with
---  this work for additional information regarding copyright ownership.
---  The ASF licenses this file to You under the Apache License, Version 2.0
---  (the "License"); you may not use this file except in compliance with
---  the License.  You may obtain a copy of the License at
---
---       http://www.apache.org/licenses/LICENSE-2.0
---
---  Unless required by applicable law or agreed to in writing, software
---  distributed under the License is distributed on an "AS IS" BASIS,
---  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
---  See the License for the specific language governing permissions and
---  limitations under the License.
-
-
---
--- This script is used to pre-populate the database for Schema Import Demo.
--- It can be executed on H2 database available with Ignite.
--- You can start H2 database server with "h2-server.sh" or "h2-server.bat" scripts.
--- When started, copy the SQL below into H2 console and execute.
---
-
-drop table PERSON;
-
-create table PERSON(id bigint not null, first_name varchar(50), last_name varchar(50), PRIMARY
KEY(id));
-
-insert into PERSON(id, first_name, last_name) values(1, 'first-name-1', 'last-name-1');
-insert into PERSON(id, first_name, last_name) values(2, 'first-name-2', 'last-name-2');
-insert into PERSON(id, first_name, last_name) values(3, 'first-name-3', 'last-name-3');
-insert into PERSON(id, first_name, last_name) values(4, 'first-name-4', 'last-name-4');
-insert into PERSON(id, first_name, last_name) values(5, 'first-name-5', 'last-name-5');
-insert into PERSON(id, first_name, last_name) values(6, 'first-name-6', 'last-name-6');
-insert into PERSON(id, first_name, last_name) values(7, 'first-name-7', 'last-name-7');
-insert into PERSON(id, first_name, last_name) values(8, 'first-name-8', 'last-name-8');
-insert into PERSON(id, first_name, last_name) values(9, 'first-name-9', 'last-name-9');
-insert into PERSON(id, first_name, last_name) values(10, 'first-name-10', 'last-name-10');

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f32b7ed/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPojoPersonStore.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPojoPersonStore.java
b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPojoPersonStore.java
index 86f3403..4d88463 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPojoPersonStore.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPojoPersonStore.java
@@ -20,7 +20,6 @@ package org.apache.ignite.examples.datagrid.store.jdbc;
 import org.apache.ignite.*;
 import org.apache.ignite.cache.store.jdbc.*;
 import org.apache.ignite.examples.datagrid.store.model.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
 import org.h2.tools.*;
 
 import javax.cache.*;
@@ -52,6 +51,16 @@ public class CacheJdbcPojoPersonStore extends CacheJdbcPojoStore<Long,
Person> {
         }
     }
 
+    /** */
+    private static final String DB_SCRIPT =
+        "create table PERSON(id bigint not null, first_name varchar(50), last_name varchar(50),
PRIMARY KEY(id));\n" +
+        "insert into PERSON(id, first_name, last_name) values(1, 'Johannes', 'Kepler');\n"
+
+        "insert into PERSON(id, first_name, last_name) values(2, 'Galileo', 'Galilei');\n"
+
+        "insert into PERSON(id, first_name, last_name) values(3, 'Henry', 'More');\n" +
+        "insert into PERSON(id, first_name, last_name) values(4, 'Polish', 'Brethren');\n"
+
+        "insert into PERSON(id, first_name, last_name) values(5, 'Robert', 'Boyle');\n" +
+        "insert into PERSON(id, first_name, last_name) values(6, 'Isaac', 'Newton');";
+
     /**
      * Prepares database for example execution. This method will create a table called "PERSONS"
      * so it can be used by store implementation.
@@ -59,24 +68,15 @@ public class CacheJdbcPojoPersonStore extends CacheJdbcPojoStore<Long,
Person> {
      * @throws IgniteException If failed.
      */
     private void prepareDb() throws IgniteException {
-        File script = U.resolveIgnitePath("examples/config/store/example-database.script");
-
-        if (script == null)
-            throw new IgniteException("Failed to find example database script: " +
-                "examples/config/store/example-database.script");
-
         try {
             // Start H2 database TCP server in order to access sample in-memory database
from other processes.
             Server.createTcpServer("-tcpDaemon").start();
 
             // Load sample data into database.
-            RunScript.execute(dataSrc.getConnection(), new FileReader(script));
+            RunScript.execute(dataSrc.getConnection(), new StringReader(DB_SCRIPT));
         }
         catch (SQLException e) {
             throw new IgniteException("Failed to initialize database", e);
         }
-        catch (FileNotFoundException e) {
-            throw new IgniteException("Failed to find example database script: " + script.getPath(),
e);
-        }
     }
 }


Mime
View raw message