From abd996accaa800d38f2fe507a31bc5394ca6f9b3 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 10 Nov 2016 09:37:41 -0800 Subject: [PATCH 01/68] added environment variables --- src/main/resources/application.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 4e8c8f5..503a1f0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,3 @@ -spring.datasource.url= jdbc:mysql://localhost:3306/dev?useSSL=false -spring.datasource.username=root -spring.datasource.password= +spring.datasource.url= jdbc:mysql://$MYSQL_SERVICE_HOST:$MYSQL_PORT/$MYSQL_DATABASE?useSSL=false +spring.datasource.username=$MYSQL_USER +spring.datasource.password=$MYSQL_PASSWORD From b8486023e662595635c103857e701fe9a9036277 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 10 Nov 2016 10:35:41 -0800 Subject: [PATCH 02/68] Update application.properties --- src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 503a1f0..d936db9 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,3 @@ -spring.datasource.url= jdbc:mysql://$MYSQL_SERVICE_HOST:$MYSQL_PORT/$MYSQL_DATABASE?useSSL=false +spring.datasource.url= jdbc:mysql://$MYSQL_SERVICE_HOST:$MYSQL_SERVICE_PORT/$MYSQL_DATABASE?useSSL=false spring.datasource.username=$MYSQL_USER spring.datasource.password=$MYSQL_PASSWORD From 392f840bb04e85ebec8ae31d42bb4c6f9710c924 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 10 Nov 2016 10:48:56 -0800 Subject: [PATCH 03/68] number format --- src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d936db9..fb2d20b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,3 @@ -spring.datasource.url= jdbc:mysql://$MYSQL_SERVICE_HOST:$MYSQL_SERVICE_PORT/$MYSQL_DATABASE?useSSL=false +spring.datasource.url= jdbc:mysql://$MYSQL_SERVICE_HOST:(java.lang.Integer)${MYSQL_SERVICE_PORT}/$MYSQL_DATABASE?useSSL=false spring.datasource.username=$MYSQL_USER spring.datasource.password=$MYSQL_PASSWORD From ed0422e1c475a20bfde5a1c7cb1b3ab3f502494a Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 10 Nov 2016 10:57:28 -0800 Subject: [PATCH 04/68] Update application.properties --- src/main/resources/application.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fb2d20b..10aadd6 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,4 @@ -spring.datasource.url= jdbc:mysql://$MYSQL_SERVICE_HOST:(java.lang.Integer)${MYSQL_SERVICE_PORT}/$MYSQL_DATABASE?useSSL=false +spring.datasource.port=(java.lang.Integer)${MYSQL_SERVICE_PORT} +spring.datasource.url= jdbc:mysql://$MYSQL_SERVICE_HOST:3306/$MYSQL_DATABASE?useSSL=false spring.datasource.username=$MYSQL_USER spring.datasource.password=$MYSQL_PASSWORD From 0ff2e32cd8f541b3340f25cb6e82a481f9881741 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 10 Nov 2016 12:26:36 -0800 Subject: [PATCH 05/68] Update SpringSampleAppApplication.java --- src/main/java/com/example/SpringSampleAppApplication.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index 7cf9600..911a28b 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -69,6 +69,7 @@ public String cancer(){ public String dbtest(){ String sql = "SELECT * FROM customer"; + System.out.println ("connection info"+env.getProperty("spring.datasource.url")); Connection conn = null; try { From dcb4317977ede3ba7af5c01b3dfe72aef0d8661b Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 10 Nov 2016 12:31:30 -0800 Subject: [PATCH 06/68] Update application.properties --- src/main/resources/application.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 10aadd6..1a82a28 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,4 @@ spring.datasource.port=(java.lang.Integer)${MYSQL_SERVICE_PORT} -spring.datasource.url= jdbc:mysql://$MYSQL_SERVICE_HOST:3306/$MYSQL_DATABASE?useSSL=false -spring.datasource.username=$MYSQL_USER -spring.datasource.password=$MYSQL_PASSWORD +spring.datasource.url= jdbc:mysql://${MYSQL_SERVICE_HOST}:3306/${MYSQL_DATABASE}?useSSL=false +spring.datasource.username=${MYSQL_USER} +spring.datasource.password=${MYSQL_PASSWORD} From d0d4dea07232f0e97c85bb4a0aafe6c5ad6a5d9a Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 10 Nov 2016 17:19:57 -0500 Subject: [PATCH 07/68] Update SpringSampleAppApplication.java --- src/main/java/com/example/SpringSampleAppApplication.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index 911a28b..fb33b83 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -69,11 +69,11 @@ public String cancer(){ public String dbtest(){ String sql = "SELECT * FROM customer"; - System.out.println ("connection info"+env.getProperty("spring.datasource.url")); Connection conn = null; try { - conn = DriverManager.getConnection(env.getProperty("spring.datasource.url"),env.getProperty("spring.datasource.username"),env.getProperty("spring.datasource.password")); + //conn = DriverManager.getConnection(env.getProperty("spring.datasource.url"),env.getProperty("spring.datasource.username"),env.getProperty("spring.datasource.password")); + conn = DriverManager.getConnection("jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":3306/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false",env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); rs.next(); From 0250b773d0ed19ad43ef54d1a00b30d547e7aa09 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 10 Nov 2016 17:26:54 -0500 Subject: [PATCH 08/68] Update SpringSampleAppApplication.java --- src/main/java/com/example/SpringSampleAppApplication.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index fb33b83..08bc794 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -73,6 +73,8 @@ public String dbtest(){ try { //conn = DriverManager.getConnection(env.getProperty("spring.datasource.url"),env.getProperty("spring.datasource.username"),env.getProperty("spring.datasource.password")); + connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":3306/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; + System.out.println("URL: "+connURL); conn = DriverManager.getConnection("jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":3306/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false",env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); From 2f4113fa0d3c351871096a0cf302e75d05ad70c2 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 10 Nov 2016 17:28:17 -0500 Subject: [PATCH 09/68] Update SpringSampleAppApplication.java --- src/main/java/com/example/SpringSampleAppApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index 08bc794..0f4f8a7 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -73,7 +73,7 @@ public String dbtest(){ try { //conn = DriverManager.getConnection(env.getProperty("spring.datasource.url"),env.getProperty("spring.datasource.username"),env.getProperty("spring.datasource.password")); - connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":3306/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; + String connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":3306/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; System.out.println("URL: "+connURL); conn = DriverManager.getConnection("jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":3306/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false",env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); PreparedStatement ps = conn.prepareStatement(sql); From 4840eb18a403e8fc2d2dcfecb6afc7a1949f36df Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 10 Nov 2016 17:38:02 -0500 Subject: [PATCH 10/68] Update SpringSampleAppApplication.java --- src/main/java/com/example/SpringSampleAppApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index 0f4f8a7..3618d24 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -75,7 +75,7 @@ public String dbtest(){ //conn = DriverManager.getConnection(env.getProperty("spring.datasource.url"),env.getProperty("spring.datasource.username"),env.getProperty("spring.datasource.password")); String connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":3306/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; System.out.println("URL: "+connURL); - conn = DriverManager.getConnection("jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":3306/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false",env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); + conn = DriverManager.getConnection(connURL,env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); rs.next(); From b08087c471e09c4f11cf1a28b0fa1220e548c2a1 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Fri, 11 Nov 2016 13:20:19 -0500 Subject: [PATCH 11/68] looping through customers --- .../java/com/example/SpringSampleAppApplication.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index 3618d24..d59145c 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -73,13 +73,17 @@ public String dbtest(){ try { //conn = DriverManager.getConnection(env.getProperty("spring.datasource.url"),env.getProperty("spring.datasource.username"),env.getProperty("spring.datasource.password")); - String connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":3306/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; + String connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":"+env.getProperty("MYSQL_SERVICE_PORT")+"/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; System.out.println("URL: "+connURL); conn = DriverManager.getConnection(connURL,env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); - rs.next(); - String res="

"+rs.getInt("CUST_ID") + rs.getString("NAME")+rs.getInt("Age")+"

"; + String res="

Customers List


" + while (rs.next()) { + res=res+"

CustomerId: "+rs.getInt("CUST_ID") + "Customer Name: "+ rs.getString("NAME")+"Age: "+rs.getInt("Age")+"


"; + } finally { + rs.close(); + } return res; } catch (SQLException e) { throw new RuntimeException(e); From 501815cf0cd92fcdb283f2fe942ecb18b9a40a4f Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Fri, 11 Nov 2016 13:22:13 -0500 Subject: [PATCH 12/68] Update SpringSampleAppApplication.java --- src/main/java/com/example/SpringSampleAppApplication.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index d59145c..bbba095 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -81,15 +81,14 @@ public String dbtest(){ String res="

Customers List


" while (rs.next()) { res=res+"

CustomerId: "+rs.getInt("CUST_ID") + "Customer Name: "+ rs.getString("NAME")+"Age: "+rs.getInt("Age")+"


"; - } finally { - rs.close(); - } + } return res; } catch (SQLException e) { throw new RuntimeException(e); } finally { if (conn != null) { try { + rs.close(); conn.close(); } catch (SQLException e) {} } From 801721aa584d443cdedcbb8bce135c054db0e0f1 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Fri, 11 Nov 2016 13:27:20 -0500 Subject: [PATCH 13/68] Update SpringSampleAppApplication.java --- src/main/java/com/example/SpringSampleAppApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index bbba095..432df98 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -78,7 +78,7 @@ public String dbtest(){ conn = DriverManager.getConnection(connURL,env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); - String res="

Customers List


" + String res="

Customers List


"; while (rs.next()) { res=res+"

CustomerId: "+rs.getInt("CUST_ID") + "Customer Name: "+ rs.getString("NAME")+"Age: "+rs.getInt("Age")+"


"; } From 44cd001d9caccaa55f7e13f69b737acb17ca9ba8 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Fri, 11 Nov 2016 13:30:44 -0500 Subject: [PATCH 14/68] Update SpringSampleAppApplication.java --- src/main/java/com/example/SpringSampleAppApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index 432df98..f068395 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -82,13 +82,13 @@ public String dbtest(){ while (rs.next()) { res=res+"

CustomerId: "+rs.getInt("CUST_ID") + "Customer Name: "+ rs.getString("NAME")+"Age: "+rs.getInt("Age")+"


"; } + rs.close(); return res; } catch (SQLException e) { throw new RuntimeException(e); } finally { if (conn != null) { try { - rs.close(); conn.close(); } catch (SQLException e) {} } From 7333bf507821e054871c4312a50a6a8f87f95338 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Fri, 11 Nov 2016 13:33:38 -0500 Subject: [PATCH 15/68] Update SpringSampleAppApplication.java --- src/main/java/com/example/SpringSampleAppApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index f068395..ef17437 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -80,7 +80,7 @@ public String dbtest(){ ResultSet rs = ps.executeQuery(); String res="

Customers List


"; while (rs.next()) { - res=res+"

CustomerId: "+rs.getInt("CUST_ID") + "Customer Name: "+ rs.getString("NAME")+"Age: "+rs.getInt("Age")+"


"; + res=res+"CustomerId: "+rs.getInt("CUST_ID") + " Customer Name: "+ rs.getString("NAME")+" Age: "+rs.getInt("Age")+"
"; } rs.close(); return res; From bd2cdd53bd3ff7b27a6a340b8e6472619a875453 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Fri, 11 Nov 2016 16:12:54 -0500 Subject: [PATCH 16/68] Update pom.xml --- pom.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pom.xml b/pom.xml index eff5d1c..dd8cb56 100644 --- a/pom.xml +++ b/pom.xml @@ -30,6 +30,15 @@ mysql-connector-java 5.1.6 + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework.boot + spring-boot-starter-data-jpa + + org.springframework.boot From ae3bc1522cfee5979b5a164ecd92f7add52d23c5 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Fri, 11 Nov 2016 16:18:25 -0500 Subject: [PATCH 17/68] Update pom.xml --- pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pom.xml b/pom.xml index dd8cb56..822069d 100644 --- a/pom.xml +++ b/pom.xml @@ -34,11 +34,6 @@ org.springframework.boot spring-boot-starter-jdbc - - org.springframework.boot - spring-boot-starter-data-jpa - - org.springframework.boot From cbdfe42725645639a7c1e3e2d9cbd124039bb451 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Fri, 11 Nov 2016 16:23:58 -0500 Subject: [PATCH 18/68] moved schema.sql --- schema.sql | 1 - src/main/resources/schema.sql | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 schema.sql create mode 100644 src/main/resources/schema.sql diff --git a/schema.sql b/schema.sql deleted file mode 100644 index 7a8eb9f..0000000 --- a/schema.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE TABLE `customer` ( `CUST_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(100) NOT NULL, `AGE` int(10) unsigned NOT NULL, PRIMARY KEY (`CUST_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql new file mode 100644 index 0000000..adf9c9c --- /dev/null +++ b/src/main/resources/schema.sql @@ -0,0 +1 @@ +CREATE TABLE IF NOT EXISTS `customer` ( `CUST_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(100) NOT NULL, `AGE` int(10) unsigned NOT NULL, PRIMARY KEY (`CUST_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; From ad078f6b403d1b29eebb922dfd3aaaccecc192ae Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Fri, 11 Nov 2016 16:38:05 -0500 Subject: [PATCH 19/68] chagned app properties --- src/main/resources/application.properties | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 1a82a28..a273c95 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,3 @@ -spring.datasource.port=(java.lang.Integer)${MYSQL_SERVICE_PORT} -spring.datasource.url= jdbc:mysql://${MYSQL_SERVICE_HOST}:3306/${MYSQL_DATABASE}?useSSL=false -spring.datasource.username=${MYSQL_USER} -spring.datasource.password=${MYSQL_PASSWORD} +spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false +spring.datasource.username=user +spring.datasource.password=password From 0b89eb675d04d7dba63d976b26414ed61618acee Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Fri, 11 Nov 2016 16:44:07 -0500 Subject: [PATCH 20/68] added data.sql --- src/main/resources/data.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/main/resources/data.sql diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql new file mode 100644 index 0000000..21b0b84 --- /dev/null +++ b/src/main/resources/data.sql @@ -0,0 +1,4 @@ +insert into customer values (null, "Joe", 88); +insert into customer values (null, "Jack", 54); +insert into customer values (null, "Ann", 32); + From 2c5889e3000da2d6ddc318d39279fb32ff068fa6 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Fri, 11 Nov 2016 17:19:26 -0500 Subject: [PATCH 21/68] added data.sql --- src/main/resources/application.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a273c95..e80deb2 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,3 @@ -spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false -spring.datasource.username=user -spring.datasource.password=password +#spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false +#spring.datasource.username=user +#spring.datasource.password=password From 1e2402f2a10f2e176cba221a7d056dc77607fb1c Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Tue, 15 Nov 2016 12:28:56 -0500 Subject: [PATCH 22/68] Update application.properties --- src/main/resources/application.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e80deb2..a273c95 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,3 @@ -#spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false -#spring.datasource.username=user -#spring.datasource.password=password +spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false +spring.datasource.username=user +spring.datasource.password=password From cd2d261caef066680d8ccdbbf75457ce5883479e Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Tue, 15 Nov 2016 13:00:24 -0500 Subject: [PATCH 23/68] Update data.sql --- src/main/resources/data.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 21b0b84..a959074 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -1,3 +1,4 @@ +delete * from customer; insert into customer values (null, "Joe", 88); insert into customer values (null, "Jack", 54); insert into customer values (null, "Ann", 32); From a787304510f0fac182da9c274165607f38e67c70 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Tue, 15 Nov 2016 13:02:09 -0500 Subject: [PATCH 24/68] Update SpringSampleAppApplication.java --- src/main/java/com/example/SpringSampleAppApplication.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index ef17437..529423a 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -72,10 +72,10 @@ public String dbtest(){ Connection conn = null; try { - //conn = DriverManager.getConnection(env.getProperty("spring.datasource.url"),env.getProperty("spring.datasource.username"),env.getProperty("spring.datasource.password")); - String connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":"+env.getProperty("MYSQL_SERVICE_PORT")+"/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; - System.out.println("URL: "+connURL); - conn = DriverManager.getConnection(connURL,env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); + conn = DriverManager.getConnection(env.getProperty("spring.datasource.url"),env.getProperty("spring.datasource.username"),env.getProperty("spring.datasource.password")); + //String connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":"+env.getProperty("MYSQL_SERVICE_PORT")+"/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; + //System.out.println("URL: "+connURL); + //conn = DriverManager.getConnection(connURL,env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); String res="

Customers List


"; From 4c18277c962fcbbf72a432682fe6114bb169bc08 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Tue, 15 Nov 2016 15:11:12 -0500 Subject: [PATCH 25/68] Update data.sql --- src/main/resources/data.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index a959074..ceb5374 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -1,4 +1,4 @@ -delete * from customer; +delete from customer; insert into customer values (null, "Joe", 88); insert into customer values (null, "Jack", 54); insert into customer values (null, "Ann", 32); From d932109ac533933cffb994782f40b6edf1c6d852 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Tue, 15 Nov 2016 15:36:50 -0500 Subject: [PATCH 26/68] Update SpringSampleAppApplication.java --- src/main/java/com/example/SpringSampleAppApplication.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index 529423a..fd5d04c 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -76,6 +76,7 @@ public String dbtest(){ //String connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":"+env.getProperty("MYSQL_SERVICE_PORT")+"/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; //System.out.println("URL: "+connURL); //conn = DriverManager.getConnection(connURL,env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); + System.out.println("Username: "+env.getProperty("spring.datasource.username")+"\nPassword: "+env.getProperty("spring.datasource.password")); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); String res="

Customers List


"; From 22b583774fd0b3a8c7b12d1e1b76543103faa238 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Tue, 15 Nov 2016 20:59:20 -0500 Subject: [PATCH 27/68] commented application props --- src/main/resources/application.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a273c95..e80deb2 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,3 @@ -spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false -spring.datasource.username=user -spring.datasource.password=password +#spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false +#spring.datasource.username=user +#spring.datasource.password=password From 6c387ae59797220713ab6613f933b61ec6a5bc58 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 08:54:37 -0500 Subject: [PATCH 28/68] removed jdbc plugin to test --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 822069d..9e6eb59 100644 --- a/pom.xml +++ b/pom.xml @@ -30,11 +30,12 @@ mysql-connector-java 5.1.6
+ org.springframework.boot spring-boot-starter-web From d24925aaa3e6e5a2dd5b579da7d3237300cb713b Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 10:03:25 -0500 Subject: [PATCH 29/68] split non-database and database --- README.md => simple/README.md | 0 pom.xml => simple/pom.xml | 0 .../src}/main/java/com/example/SpringSampleAppApplication.java | 0 {src => simple/src}/main/resources/application.properties | 0 {src => simple/src}/main/resources/data.sql | 0 {src => simple/src}/main/resources/schema.sql | 0 .../test/java/com/example/SpringSampleAppApplicationTests.java | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename README.md => simple/README.md (100%) rename pom.xml => simple/pom.xml (100%) rename {src => simple/src}/main/java/com/example/SpringSampleAppApplication.java (100%) rename {src => simple/src}/main/resources/application.properties (100%) rename {src => simple/src}/main/resources/data.sql (100%) rename {src => simple/src}/main/resources/schema.sql (100%) rename {src => simple/src}/test/java/com/example/SpringSampleAppApplicationTests.java (100%) diff --git a/README.md b/simple/README.md similarity index 100% rename from README.md rename to simple/README.md diff --git a/pom.xml b/simple/pom.xml similarity index 100% rename from pom.xml rename to simple/pom.xml diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/simple/src/main/java/com/example/SpringSampleAppApplication.java similarity index 100% rename from src/main/java/com/example/SpringSampleAppApplication.java rename to simple/src/main/java/com/example/SpringSampleAppApplication.java diff --git a/src/main/resources/application.properties b/simple/src/main/resources/application.properties similarity index 100% rename from src/main/resources/application.properties rename to simple/src/main/resources/application.properties diff --git a/src/main/resources/data.sql b/simple/src/main/resources/data.sql similarity index 100% rename from src/main/resources/data.sql rename to simple/src/main/resources/data.sql diff --git a/src/main/resources/schema.sql b/simple/src/main/resources/schema.sql similarity index 100% rename from src/main/resources/schema.sql rename to simple/src/main/resources/schema.sql diff --git a/src/test/java/com/example/SpringSampleAppApplicationTests.java b/simple/src/test/java/com/example/SpringSampleAppApplicationTests.java similarity index 100% rename from src/test/java/com/example/SpringSampleAppApplicationTests.java rename to simple/src/test/java/com/example/SpringSampleAppApplicationTests.java From db55a0c9b7182772231fe688b1c9c4713a7e2ef1 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 11:35:45 -0500 Subject: [PATCH 30/68] added 2tier app --- 2tier/README.md | 1 + 2tier/pom.xml | 67 ++++++++++++ .../example/SpringSampleAppApplication.java | 100 ++++++++++++++++++ .../main/resources/app-properties.template | 5 + 2tier/src/main/resources/data.sql | 5 + 2tier/src/main/resources/schema.sql | 1 + .../SpringSampleAppApplicationTests.java | 16 +++ 7 files changed, 195 insertions(+) create mode 100644 2tier/README.md create mode 100644 2tier/pom.xml create mode 100644 2tier/src/main/java/com/example/SpringSampleAppApplication.java create mode 100644 2tier/src/main/resources/app-properties.template create mode 100644 2tier/src/main/resources/data.sql create mode 100644 2tier/src/main/resources/schema.sql create mode 100644 2tier/src/test/java/com/example/SpringSampleAppApplicationTests.java diff --git a/2tier/README.md b/2tier/README.md new file mode 100644 index 0000000..80806f8 --- /dev/null +++ b/2tier/README.md @@ -0,0 +1 @@ +# spring-sample-app diff --git a/2tier/pom.xml b/2tier/pom.xml new file mode 100644 index 0000000..390dc20 --- /dev/null +++ b/2tier/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + + com.example + spring-sample-app + 0.0.1-SNAPSHOT + jar + + spring-sample-app + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 1.4.1.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + + + + + mysql + mysql-connector-java + 5.1.6 + + + + org.springframework.boot + spring-boot-starter-jdbc + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + mysql + mysql-connector-java + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/2tier/src/main/java/com/example/SpringSampleAppApplication.java b/2tier/src/main/java/com/example/SpringSampleAppApplication.java new file mode 100644 index 0000000..fd5d04c --- /dev/null +++ b/2tier/src/main/java/com/example/SpringSampleAppApplication.java @@ -0,0 +1,100 @@ +package com.example; + +import org.springframework.boot.SpringApplication; +import org.springframework.http.ResponseEntity; +import org.springframework.http.HttpStatus; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.Console; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.DriverManager; +import javax.sql.DataSource; +import org.springframework.core.env.Environment; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@SpringBootApplication +public class SpringSampleAppApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringSampleAppApplication.class, args); + } +} + +@RestController +@RequestMapping("/") +class HomeRestController { + + boolean healthy=true; + String hostname=""; + public HomeRestController(){ + try { + hostname= "Hello from " + InetAddress.getLocalHost().getHostName().toString(); + } + catch (UnknownHostException ex){ + hostname= "error"; + } + } + + @RequestMapping("/") + public String home(){ + return "

"+hostname+"

"; + } + + @RequestMapping("/healthz") + public ResponseEntity healthz(){ + if (healthy) + return new ResponseEntity(HttpStatus.ACCEPTED); + else + return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE); + } + + @RequestMapping("/cancer") + public String cancer(){ + healthy=false; + return "Killed "+hostname; + } + + @Autowired + private Environment env; + + @RequestMapping("/dbtest") + public String dbtest(){ + + String sql = "SELECT * FROM customer"; + Connection conn = null; + + try { + conn = DriverManager.getConnection(env.getProperty("spring.datasource.url"),env.getProperty("spring.datasource.username"),env.getProperty("spring.datasource.password")); + //String connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":"+env.getProperty("MYSQL_SERVICE_PORT")+"/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; + //System.out.println("URL: "+connURL); + //conn = DriverManager.getConnection(connURL,env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); + System.out.println("Username: "+env.getProperty("spring.datasource.username")+"\nPassword: "+env.getProperty("spring.datasource.password")); + PreparedStatement ps = conn.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + String res="

Customers List


"; + while (rs.next()) { + res=res+"CustomerId: "+rs.getInt("CUST_ID") + " Customer Name: "+ rs.getString("NAME")+" Age: "+rs.getInt("Age")+"
"; + } + rs.close(); + return res; + } catch (SQLException e) { + throw new RuntimeException(e); + } finally { + if (conn != null) { + try { + conn.close(); + } catch (SQLException e) {} + } + } + } + + +} diff --git a/2tier/src/main/resources/app-properties.template b/2tier/src/main/resources/app-properties.template new file mode 100644 index 0000000..2816262 --- /dev/null +++ b/2tier/src/main/resources/app-properties.template @@ -0,0 +1,5 @@ +# replace your own values based on the database service you created +# url = jdbc:mysql://<>:<>/<>?useSSL=false +spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false +spring.datasource.username=user +spring.datasource.password=password diff --git a/2tier/src/main/resources/data.sql b/2tier/src/main/resources/data.sql new file mode 100644 index 0000000..ceb5374 --- /dev/null +++ b/2tier/src/main/resources/data.sql @@ -0,0 +1,5 @@ +delete from customer; +insert into customer values (null, "Joe", 88); +insert into customer values (null, "Jack", 54); +insert into customer values (null, "Ann", 32); + diff --git a/2tier/src/main/resources/schema.sql b/2tier/src/main/resources/schema.sql new file mode 100644 index 0000000..adf9c9c --- /dev/null +++ b/2tier/src/main/resources/schema.sql @@ -0,0 +1 @@ +CREATE TABLE IF NOT EXISTS `customer` ( `CUST_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(100) NOT NULL, `AGE` int(10) unsigned NOT NULL, PRIMARY KEY (`CUST_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; diff --git a/2tier/src/test/java/com/example/SpringSampleAppApplicationTests.java b/2tier/src/test/java/com/example/SpringSampleAppApplicationTests.java new file mode 100644 index 0000000..3ed3863 --- /dev/null +++ b/2tier/src/test/java/com/example/SpringSampleAppApplicationTests.java @@ -0,0 +1,16 @@ +package com.example; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class SpringSampleAppApplicationTests { + + @Test + public void contextLoads() { + } + +} From 18124238eeb7d5133823b7533a1a7231afa668be Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 12:13:17 -0500 Subject: [PATCH 31/68] disable testing --- 2tier/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2tier/pom.xml b/2tier/pom.xml index 390dc20..ecf1897 100644 --- a/2tier/pom.xml +++ b/2tier/pom.xml @@ -40,13 +40,13 @@ org.springframework.boot spring-boot-starter-web
- + mysql mysql-connector-java From 853f3783439f4d8763d9b18685ab2af7458e5efd Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 13:43:25 -0500 Subject: [PATCH 32/68] added application properties --- 2tier/pom.xml | 4 ++-- .../{app-properties.template => application.properties} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename 2tier/src/main/resources/{app-properties.template => application.properties} (100%) diff --git a/2tier/pom.xml b/2tier/pom.xml index ecf1897..a3fd5f9 100644 --- a/2tier/pom.xml +++ b/2tier/pom.xml @@ -40,13 +40,13 @@ org.springframework.boot spring-boot-starter-web - + mysql mysql-connector-java diff --git a/2tier/src/main/resources/app-properties.template b/2tier/src/main/resources/application.properties similarity index 100% rename from 2tier/src/main/resources/app-properties.template rename to 2tier/src/main/resources/application.properties From 719b8b5df289a9e6ba63348fa847d2189e0d519e Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 13:56:28 -0500 Subject: [PATCH 33/68] added refresh scope --- 2tier/src/main/java/com/example/SpringSampleAppApplication.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/2tier/src/main/java/com/example/SpringSampleAppApplication.java b/2tier/src/main/java/com/example/SpringSampleAppApplication.java index fd5d04c..0cdd1a3 100644 --- a/2tier/src/main/java/com/example/SpringSampleAppApplication.java +++ b/2tier/src/main/java/com/example/SpringSampleAppApplication.java @@ -30,6 +30,7 @@ public static void main(String[] args) { @RestController @RequestMapping("/") +@RefreshScope class HomeRestController { boolean healthy=true; @@ -76,6 +77,7 @@ public String dbtest(){ //String connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":"+env.getProperty("MYSQL_SERVICE_PORT")+"/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; //System.out.println("URL: "+connURL); //conn = DriverManager.getConnection(connURL,env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); + System.out.println("connection url: "+env.getProperty("spring.datasource.url")); System.out.println("Username: "+env.getProperty("spring.datasource.username")+"\nPassword: "+env.getProperty("spring.datasource.password")); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); From 38210afa404f7493147ad43a9b3f46c711d9f0a5 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 13:58:30 -0500 Subject: [PATCH 34/68] added refresh scope --- 2tier/src/main/java/com/example/SpringSampleAppApplication.java | 1 + 1 file changed, 1 insertion(+) diff --git a/2tier/src/main/java/com/example/SpringSampleAppApplication.java b/2tier/src/main/java/com/example/SpringSampleAppApplication.java index 0cdd1a3..9e29706 100644 --- a/2tier/src/main/java/com/example/SpringSampleAppApplication.java +++ b/2tier/src/main/java/com/example/SpringSampleAppApplication.java @@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.cloud.context.config.annotation.RefreshScope; import java.io.Console; import java.net.InetAddress; From 6a8e8dcb790b5114b5ad7e712a401c62788ad59f Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 14:33:45 -0500 Subject: [PATCH 35/68] added maven dependency --- 2tier/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/2tier/pom.xml b/2tier/pom.xml index a3fd5f9..3fe2929 100644 --- a/2tier/pom.xml +++ b/2tier/pom.xml @@ -46,6 +46,13 @@ spring-boot-starter-test test + + + + org.springframework.cloud + spring-cloud-config-client + 1.0.0.RELEASE + mysql From 4443cd929c1cfb3a93773665f7de8a244a56d777 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 14:58:21 -0500 Subject: [PATCH 36/68] added maven dependency --- 2tier/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/2tier/pom.xml b/2tier/pom.xml index 3fe2929..c5a8c3d 100644 --- a/2tier/pom.xml +++ b/2tier/pom.xml @@ -51,7 +51,6 @@ org.springframework.cloud spring-cloud-config-client - 1.0.0.RELEASE From 21912ea6030a5ddab6255bb6c22e51b60b338e22 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 15:00:07 -0500 Subject: [PATCH 37/68] added maven dependency --- 2tier/pom.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/2tier/pom.xml b/2tier/pom.xml index c5a8c3d..faf77f9 100644 --- a/2tier/pom.xml +++ b/2tier/pom.xml @@ -47,16 +47,17 @@ test + + mysql + mysql-connector-java + + org.springframework.cloud spring-cloud-config-client - - mysql - mysql-connector-java - From 068c4d6cbb99d5dc1936d14ba2abf81f04079304 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 15:08:19 -0500 Subject: [PATCH 38/68] added maven dependency --- 2tier/pom.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/2tier/pom.xml b/2tier/pom.xml index faf77f9..a9e9027 100644 --- a/2tier/pom.xml +++ b/2tier/pom.xml @@ -47,15 +47,11 @@ test - - mysql - mysql-connector-java - org.springframework.cloud - spring-cloud-config-client + spring-cloud-config-server From 9b3840767756c2bd355b90ff99e51ae4312077f8 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 15:17:03 -0500 Subject: [PATCH 39/68] added maven dependency --- 2tier/pom.xml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/2tier/pom.xml b/2tier/pom.xml index a9e9027..5b1dbcc 100644 --- a/2tier/pom.xml +++ b/2tier/pom.xml @@ -18,6 +18,19 @@ + + + + + org.springframework.cloud + spring-cloud-starter + 1.1.5.RELEASE + pom + import + + + + UTF-8 UTF-8 @@ -48,10 +61,9 @@ - org.springframework.cloud - spring-cloud-config-server + spring-cloud-config-client From 681721ffdc339099fa4b5eefbdcd764ebbd3a843 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 15:23:57 -0500 Subject: [PATCH 40/68] added maven dependency --- 2tier/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/2tier/pom.xml b/2tier/pom.xml index 5b1dbcc..cd39e47 100644 --- a/2tier/pom.xml +++ b/2tier/pom.xml @@ -64,6 +64,7 @@ org.springframework.cloud spring-cloud-config-client + 1.2.1.RELEASE From a1639815b05150d5759266608833b1a0746bf4f1 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 15:49:47 -0500 Subject: [PATCH 41/68] enable autoconfiguration --- .../src/main/java/com/example/SpringSampleAppApplication.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/2tier/src/main/java/com/example/SpringSampleAppApplication.java b/2tier/src/main/java/com/example/SpringSampleAppApplication.java index 9e29706..34250c0 100644 --- a/2tier/src/main/java/com/example/SpringSampleAppApplication.java +++ b/2tier/src/main/java/com/example/SpringSampleAppApplication.java @@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import java.io.Console; import java.net.InetAddress; @@ -29,6 +30,8 @@ public static void main(String[] args) { } } + +@EnableAutoConfiguration @RestController @RequestMapping("/") @RefreshScope From 0441b43b54f019e77cca0d823dc99fb4ef265f5e Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 16:00:30 -0500 Subject: [PATCH 42/68] added @component --- .../src/main/java/com/example/SpringSampleAppApplication.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2tier/src/main/java/com/example/SpringSampleAppApplication.java b/2tier/src/main/java/com/example/SpringSampleAppApplication.java index 34250c0..2636611 100644 --- a/2tier/src/main/java/com/example/SpringSampleAppApplication.java +++ b/2tier/src/main/java/com/example/SpringSampleAppApplication.java @@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.stereotype.Component; import java.io.Console; import java.net.InetAddress; @@ -31,10 +31,10 @@ public static void main(String[] args) { } -@EnableAutoConfiguration @RestController @RequestMapping("/") @RefreshScope +@Component class HomeRestController { boolean healthy=true; From 1ab5d562abd4d07b5a5c5f96e37a8f73c594b0ae Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 16:02:33 -0500 Subject: [PATCH 43/68] added actuator dependency --- 2tier/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/2tier/pom.xml b/2tier/pom.xml index cd39e47..7840f41 100644 --- a/2tier/pom.xml +++ b/2tier/pom.xml @@ -60,6 +60,11 @@ test + + org.springframework.boot + spring-boot-starter-actuator + + org.springframework.cloud From 4b4f3107c4890def2abdb118768f6a1ceb258797 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 16:18:55 -0500 Subject: [PATCH 44/68] moved app properties --- 2tier/{src/main/resources => }/application.properties | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 2tier/{src/main/resources => }/application.properties (100%) diff --git a/2tier/src/main/resources/application.properties b/2tier/application.properties similarity index 100% rename from 2tier/src/main/resources/application.properties rename to 2tier/application.properties From fbb46ace23628e87b963a7f66000ee948c07ac1f Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 17:19:22 -0500 Subject: [PATCH 45/68] hsqldb added --- 2tier/application.properties | 3 ++- 2tier/pom.xml | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/2tier/application.properties b/2tier/application.properties index 2816262..b3ec03d 100644 --- a/2tier/application.properties +++ b/2tier/application.properties @@ -1,5 +1,6 @@ # replace your own values based on the database service you created # url = jdbc:mysql://<>:<>/<>?useSSL=false -spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false +#spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false +spring.datasource.url= jdbc:hsqldb:file:/opt/app-root/src/mydb spring.datasource.username=user spring.datasource.password=password diff --git a/2tier/pom.xml b/2tier/pom.xml index 7840f41..e164d92 100644 --- a/2tier/pom.xml +++ b/2tier/pom.xml @@ -43,6 +43,12 @@ mysql-connector-java 5.1.6 + + + org.hsqldb + hsqldb + runtime + org.springframework.boot From 854b78fba6ed37c6086441b05105ed5ecbbadce1 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 18:28:16 -0500 Subject: [PATCH 46/68] edited the create scripts --- 2tier/src/main/resources/schema.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/2tier/src/main/resources/schema.sql b/2tier/src/main/resources/schema.sql index adf9c9c..6de4cb6 100644 --- a/2tier/src/main/resources/schema.sql +++ b/2tier/src/main/resources/schema.sql @@ -1 +1,7 @@ -CREATE TABLE IF NOT EXISTS `customer` ( `CUST_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(100) NOT NULL, `AGE` int(10) unsigned NOT NULL, PRIMARY KEY (`CUST_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +#CREATE TABLE IF NOT EXISTS `customer` ( `CUST_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(100) NOT NULL, `AGE` int(10) unsigned NOT NULL, PRIMARY KEY (`CUST_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + +# HSQLDB Syntax +CREATE TABLE customer ( CUST_ID int GENERATED BY DEFAULT AS IDENTITY + (START WITH 1, INCREMENT BY 1) NOT NULL, + NAME varchar(100) NOT NULL, + AGE int(10) unsigned NOT NULL, PRIMARY KEY (CUST_ID) ); From 75cf8fa7a7102d8b33393feeae4701ec7a4d4fd7 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 18:38:41 -0500 Subject: [PATCH 47/68] edited the create scripts --- 2tier/src/main/resources/schema.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/2tier/src/main/resources/schema.sql b/2tier/src/main/resources/schema.sql index 6de4cb6..831ba3f 100644 --- a/2tier/src/main/resources/schema.sql +++ b/2tier/src/main/resources/schema.sql @@ -1,6 +1,7 @@ -#CREATE TABLE IF NOT EXISTS `customer` ( `CUST_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(100) NOT NULL, `AGE` int(10) unsigned NOT NULL, PRIMARY KEY (`CUST_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +/* CREATE TABLE IF NOT EXISTS `customer` ( `CUST_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(100) NOT NULL, `AGE` int(10) unsigned NOT NULL, PRIMARY KEY (`CUST_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +*/ -# HSQLDB Syntax +/* HSQLDB Syntax */ CREATE TABLE customer ( CUST_ID int GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL, NAME varchar(100) NOT NULL, From 80b6a998ee9777ad798b8633268e6ed4bf285bc0 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 18:43:02 -0500 Subject: [PATCH 48/68] edited the create scripts --- 2tier/src/main/resources/schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2tier/src/main/resources/schema.sql b/2tier/src/main/resources/schema.sql index 831ba3f..20814e3 100644 --- a/2tier/src/main/resources/schema.sql +++ b/2tier/src/main/resources/schema.sql @@ -5,4 +5,4 @@ CREATE TABLE customer ( CUST_ID int GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL, NAME varchar(100) NOT NULL, - AGE int(10) unsigned NOT NULL, PRIMARY KEY (CUST_ID) ); + AGE int unsigned NOT NULL, PRIMARY KEY (CUST_ID) ); From 62c2869eb8df7eef15c69931f6ae338dff709e25 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 18:45:28 -0500 Subject: [PATCH 49/68] edited the create scripts --- 2tier/src/main/resources/schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2tier/src/main/resources/schema.sql b/2tier/src/main/resources/schema.sql index 20814e3..36fd70b 100644 --- a/2tier/src/main/resources/schema.sql +++ b/2tier/src/main/resources/schema.sql @@ -5,4 +5,4 @@ CREATE TABLE customer ( CUST_ID int GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL, NAME varchar(100) NOT NULL, - AGE int unsigned NOT NULL, PRIMARY KEY (CUST_ID) ); + AGE int NOT NULL, PRIMARY KEY (CUST_ID) ); From a83db6e6a802d30bde5eea6f301b1adf3118860e Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 18:54:17 -0500 Subject: [PATCH 50/68] separated scripts by database type --- 2tier/src/main/resources/data-hsqldb.sql | 5 +++++ 2tier/src/main/resources/{data.sql => data-mysql.sql} | 0 .../src/main/resources/{schema.sql => schema-hsqldb.sql} | 0 2tier/src/main/resources/schema-mysql.sql | 8 ++++++++ 4 files changed, 13 insertions(+) create mode 100644 2tier/src/main/resources/data-hsqldb.sql rename 2tier/src/main/resources/{data.sql => data-mysql.sql} (100%) rename 2tier/src/main/resources/{schema.sql => schema-hsqldb.sql} (100%) create mode 100644 2tier/src/main/resources/schema-mysql.sql diff --git a/2tier/src/main/resources/data-hsqldb.sql b/2tier/src/main/resources/data-hsqldb.sql new file mode 100644 index 0000000..2f16544 --- /dev/null +++ b/2tier/src/main/resources/data-hsqldb.sql @@ -0,0 +1,5 @@ +delete from customer; +insert into customer (name, age) values (null, 'Joe', 88); +insert into customer (name, age) values (null, 'Jack', 54); +insert into customer (name, age) values (null, 'Ann', 32); + diff --git a/2tier/src/main/resources/data.sql b/2tier/src/main/resources/data-mysql.sql similarity index 100% rename from 2tier/src/main/resources/data.sql rename to 2tier/src/main/resources/data-mysql.sql diff --git a/2tier/src/main/resources/schema.sql b/2tier/src/main/resources/schema-hsqldb.sql similarity index 100% rename from 2tier/src/main/resources/schema.sql rename to 2tier/src/main/resources/schema-hsqldb.sql diff --git a/2tier/src/main/resources/schema-mysql.sql b/2tier/src/main/resources/schema-mysql.sql new file mode 100644 index 0000000..36fd70b --- /dev/null +++ b/2tier/src/main/resources/schema-mysql.sql @@ -0,0 +1,8 @@ +/* CREATE TABLE IF NOT EXISTS `customer` ( `CUST_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(100) NOT NULL, `AGE` int(10) unsigned NOT NULL, PRIMARY KEY (`CUST_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +*/ + +/* HSQLDB Syntax */ +CREATE TABLE customer ( CUST_ID int GENERATED BY DEFAULT AS IDENTITY + (START WITH 1, INCREMENT BY 1) NOT NULL, + NAME varchar(100) NOT NULL, + AGE int NOT NULL, PRIMARY KEY (CUST_ID) ); From 0dbac1fed97a40ef66d5b32767ab360393bf2e2c Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 19:18:14 -0500 Subject: [PATCH 51/68] drop table --- 2tier/src/main/resources/schema-hsqldb.sql | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/2tier/src/main/resources/schema-hsqldb.sql b/2tier/src/main/resources/schema-hsqldb.sql index 36fd70b..8409b3f 100644 --- a/2tier/src/main/resources/schema-hsqldb.sql +++ b/2tier/src/main/resources/schema-hsqldb.sql @@ -1,7 +1,4 @@ -/* CREATE TABLE IF NOT EXISTS `customer` ( `CUST_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(100) NOT NULL, `AGE` int(10) unsigned NOT NULL, PRIMARY KEY (`CUST_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -*/ - -/* HSQLDB Syntax */ +DROP TABLE customer IF EXISTS; CREATE TABLE customer ( CUST_ID int GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL, NAME varchar(100) NOT NULL, From 6b5ddd6b4d9bbf34082bfa3878a1b7dff9814e75 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 19:36:39 -0500 Subject: [PATCH 52/68] shutdown --- 2tier/application.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/2tier/application.properties b/2tier/application.properties index b3ec03d..43e315e 100644 --- a/2tier/application.properties +++ b/2tier/application.properties @@ -1,6 +1,7 @@ # replace your own values based on the database service you created # url = jdbc:mysql://<>:<>/<>?useSSL=false #spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false -spring.datasource.url= jdbc:hsqldb:file:/opt/app-root/src/mydb +spring.datasource.platform=hsqldb +spring.datasource.url= jdbc:hsqldb:file:/opt/app-root/src/mydb;shutdown=true spring.datasource.username=user spring.datasource.password=password From 434bd5a25f629b6abc2a385e5930b6b3f202b1a1 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 19:39:36 -0500 Subject: [PATCH 53/68] fixed data.sql --- 2tier/src/main/resources/data-hsqldb.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/2tier/src/main/resources/data-hsqldb.sql b/2tier/src/main/resources/data-hsqldb.sql index 2f16544..21208ba 100644 --- a/2tier/src/main/resources/data-hsqldb.sql +++ b/2tier/src/main/resources/data-hsqldb.sql @@ -1,5 +1,5 @@ delete from customer; -insert into customer (name, age) values (null, 'Joe', 88); -insert into customer (name, age) values (null, 'Jack', 54); -insert into customer (name, age) values (null, 'Ann', 32); +insert into customer (name, age) values ('Joe', 88); +insert into customer (name, age) values ('Jack', 54); +insert into customer (name, age) values ('Ann', 32); From a5f4f4f58d1199e55779c2deb1bf5adf52a2345e Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 20:50:18 -0500 Subject: [PATCH 54/68] fixed schema-mysql.sql --- 2tier/src/main/resources/schema-mysql.sql | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/2tier/src/main/resources/schema-mysql.sql b/2tier/src/main/resources/schema-mysql.sql index 36fd70b..a2db236 100644 --- a/2tier/src/main/resources/schema-mysql.sql +++ b/2tier/src/main/resources/schema-mysql.sql @@ -1,8 +1,3 @@ -/* CREATE TABLE IF NOT EXISTS `customer` ( `CUST_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(100) NOT NULL, `AGE` int(10) unsigned NOT NULL, PRIMARY KEY (`CUST_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -*/ +CREATE TABLE IF NOT EXISTS `customer` ( `CUST_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(100) NOT NULL, `AGE` int(10) unsigned NOT NULL, PRIMARY KEY (`CUST_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + -/* HSQLDB Syntax */ -CREATE TABLE customer ( CUST_ID int GENERATED BY DEFAULT AS IDENTITY - (START WITH 1, INCREMENT BY 1) NOT NULL, - NAME varchar(100) NOT NULL, - AGE int NOT NULL, PRIMARY KEY (CUST_ID) ); From 87c57f429217069172dbc682ddeb4474d0879b65 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 23:14:25 -0500 Subject: [PATCH 55/68] added postgresql scripts --- 2tier/src/main/resources/data-postgresql.sql | 5 +++++ 2tier/src/main/resources/schema-postgresql.sql | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 2tier/src/main/resources/data-postgresql.sql create mode 100644 2tier/src/main/resources/schema-postgresql.sql diff --git a/2tier/src/main/resources/data-postgresql.sql b/2tier/src/main/resources/data-postgresql.sql new file mode 100644 index 0000000..40d0dd0 --- /dev/null +++ b/2tier/src/main/resources/data-postgresql.sql @@ -0,0 +1,5 @@ +delete from customer; +insert into customer (name,age) values ('Joe', 88); +insert into customer (name,age) values ('Jack', 54); +insert into customer (name,age) values ('Ann', 32); + diff --git a/2tier/src/main/resources/schema-postgresql.sql b/2tier/src/main/resources/schema-postgresql.sql new file mode 100644 index 0000000..b75bb8e --- /dev/null +++ b/2tier/src/main/resources/schema-postgresql.sql @@ -0,0 +1,4 @@ +CREATE TABLE IF NOT EXISTS customer ( + CUST_ID serial primary key, + NAME varchar(100) NOT NULL, + AGE integer NOT NULL); From 8f2bd8da273be5c9d1f9de7af0db180f506bb589 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 23:28:04 -0500 Subject: [PATCH 56/68] added postgresql dependency to pom.xm --- 2tier/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/2tier/pom.xml b/2tier/pom.xml index e164d92..f22cd83 100644 --- a/2tier/pom.xml +++ b/2tier/pom.xml @@ -44,6 +44,12 @@ 5.1.6 + + org.postgresql + postgresql + 9.4-1206-jdbc42 + + org.hsqldb hsqldb From af5c9459a6d9604177d24273e4ee542649751b73 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Wed, 16 Nov 2016 23:44:19 -0500 Subject: [PATCH 57/68] removed logging un and pwd --- .../src/main/java/com/example/SpringSampleAppApplication.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2tier/src/main/java/com/example/SpringSampleAppApplication.java b/2tier/src/main/java/com/example/SpringSampleAppApplication.java index 2636611..04140fb 100644 --- a/2tier/src/main/java/com/example/SpringSampleAppApplication.java +++ b/2tier/src/main/java/com/example/SpringSampleAppApplication.java @@ -77,12 +77,12 @@ public String dbtest(){ Connection conn = null; try { - conn = DriverManager.getConnection(env.getProperty("spring.datasource.url"),env.getProperty("spring.datasource.username"),env.getProperty("spring.datasource.password")); //String connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":"+env.getProperty("MYSQL_SERVICE_PORT")+"/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; //System.out.println("URL: "+connURL); //conn = DriverManager.getConnection(connURL,env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); + conn = DriverManager.getConnection(env.getProperty("spring.datasource.url"),env.getProperty("spring.datasource.username"),env.getProperty("spring.datasource.password")); System.out.println("connection url: "+env.getProperty("spring.datasource.url")); - System.out.println("Username: "+env.getProperty("spring.datasource.username")+"\nPassword: "+env.getProperty("spring.datasource.password")); + //System.out.println("Username: "+env.getProperty("spring.datasource.username")+"\nPassword: "+env.getProperty("spring.datasource.password")); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); String res="

Customers List


"; From c5af40697df657b39f7f669b4d6d82e8f9d1ae97 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 17 Nov 2016 16:20:14 -0500 Subject: [PATCH 58/68] removed 2 versions --- 2tier/README.md => README.md | 0 ...ation.properties => application.properties | 0 2tier/pom.xml => pom.xml | 0 simple/README.md | 1 - simple/pom.xml | 67 ------------ .../example/SpringSampleAppApplication.java | 100 ------------------ .../src/main/resources/application.properties | 3 - simple/src/main/resources/data.sql | 5 - simple/src/main/resources/schema.sql | 1 - .../SpringSampleAppApplicationTests.java | 16 --- .../example/SpringSampleAppApplication.java | 0 .../main/resources/data-hsqldb.sql | 0 .../src => src}/main/resources/data-mysql.sql | 0 .../main/resources/data-postgresql.sql | 0 .../main/resources/schema-hsqldb.sql | 0 .../main/resources/schema-mysql.sql | 0 .../main/resources/schema-postgresql.sql | 0 .../SpringSampleAppApplicationTests.java | 0 18 files changed, 193 deletions(-) rename 2tier/README.md => README.md (100%) rename 2tier/application.properties => application.properties (100%) rename 2tier/pom.xml => pom.xml (100%) delete mode 100644 simple/README.md delete mode 100644 simple/pom.xml delete mode 100644 simple/src/main/java/com/example/SpringSampleAppApplication.java delete mode 100644 simple/src/main/resources/application.properties delete mode 100644 simple/src/main/resources/data.sql delete mode 100644 simple/src/main/resources/schema.sql delete mode 100644 simple/src/test/java/com/example/SpringSampleAppApplicationTests.java rename {2tier/src => src}/main/java/com/example/SpringSampleAppApplication.java (100%) rename {2tier/src => src}/main/resources/data-hsqldb.sql (100%) rename {2tier/src => src}/main/resources/data-mysql.sql (100%) rename {2tier/src => src}/main/resources/data-postgresql.sql (100%) rename {2tier/src => src}/main/resources/schema-hsqldb.sql (100%) rename {2tier/src => src}/main/resources/schema-mysql.sql (100%) rename {2tier/src => src}/main/resources/schema-postgresql.sql (100%) rename {2tier/src => src}/test/java/com/example/SpringSampleAppApplicationTests.java (100%) diff --git a/2tier/README.md b/README.md similarity index 100% rename from 2tier/README.md rename to README.md diff --git a/2tier/application.properties b/application.properties similarity index 100% rename from 2tier/application.properties rename to application.properties diff --git a/2tier/pom.xml b/pom.xml similarity index 100% rename from 2tier/pom.xml rename to pom.xml diff --git a/simple/README.md b/simple/README.md deleted file mode 100644 index 80806f8..0000000 --- a/simple/README.md +++ /dev/null @@ -1 +0,0 @@ -# spring-sample-app diff --git a/simple/pom.xml b/simple/pom.xml deleted file mode 100644 index 9e6eb59..0000000 --- a/simple/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - 4.0.0 - - com.example - spring-sample-app - 0.0.1-SNAPSHOT - jar - - spring-sample-app - Demo project for Spring Boot - - - org.springframework.boot - spring-boot-starter-parent - 1.4.1.RELEASE - - - - - UTF-8 - UTF-8 - 1.8 - - - - - mysql - mysql-connector-java - 5.1.6 - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-test - test - - - - mysql - mysql-connector-java - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - diff --git a/simple/src/main/java/com/example/SpringSampleAppApplication.java b/simple/src/main/java/com/example/SpringSampleAppApplication.java deleted file mode 100644 index fd5d04c..0000000 --- a/simple/src/main/java/com/example/SpringSampleAppApplication.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.example; - -import org.springframework.boot.SpringApplication; -import org.springframework.http.ResponseEntity; -import org.springframework.http.HttpStatus; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.io.Console; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.DriverManager; -import javax.sql.DataSource; -import org.springframework.core.env.Environment; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.ConfigurationProperties; - -@SpringBootApplication -public class SpringSampleAppApplication { - - public static void main(String[] args) { - SpringApplication.run(SpringSampleAppApplication.class, args); - } -} - -@RestController -@RequestMapping("/") -class HomeRestController { - - boolean healthy=true; - String hostname=""; - public HomeRestController(){ - try { - hostname= "Hello from " + InetAddress.getLocalHost().getHostName().toString(); - } - catch (UnknownHostException ex){ - hostname= "error"; - } - } - - @RequestMapping("/") - public String home(){ - return "

"+hostname+"

"; - } - - @RequestMapping("/healthz") - public ResponseEntity healthz(){ - if (healthy) - return new ResponseEntity(HttpStatus.ACCEPTED); - else - return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE); - } - - @RequestMapping("/cancer") - public String cancer(){ - healthy=false; - return "Killed "+hostname; - } - - @Autowired - private Environment env; - - @RequestMapping("/dbtest") - public String dbtest(){ - - String sql = "SELECT * FROM customer"; - Connection conn = null; - - try { - conn = DriverManager.getConnection(env.getProperty("spring.datasource.url"),env.getProperty("spring.datasource.username"),env.getProperty("spring.datasource.password")); - //String connURL="jdbc:mysql://"+env.getProperty("MYSQL_SERVICE_HOST")+":"+env.getProperty("MYSQL_SERVICE_PORT")+"/"+env.getProperty("MYSQL_DATABASE")+"?useSSL=false"; - //System.out.println("URL: "+connURL); - //conn = DriverManager.getConnection(connURL,env.getProperty("MYSQL_USER"),env.getProperty("MYSQL_PASSWORD")); - System.out.println("Username: "+env.getProperty("spring.datasource.username")+"\nPassword: "+env.getProperty("spring.datasource.password")); - PreparedStatement ps = conn.prepareStatement(sql); - ResultSet rs = ps.executeQuery(); - String res="

Customers List


"; - while (rs.next()) { - res=res+"CustomerId: "+rs.getInt("CUST_ID") + " Customer Name: "+ rs.getString("NAME")+" Age: "+rs.getInt("Age")+"
"; - } - rs.close(); - return res; - } catch (SQLException e) { - throw new RuntimeException(e); - } finally { - if (conn != null) { - try { - conn.close(); - } catch (SQLException e) {} - } - } - } - - -} diff --git a/simple/src/main/resources/application.properties b/simple/src/main/resources/application.properties deleted file mode 100644 index e80deb2..0000000 --- a/simple/src/main/resources/application.properties +++ /dev/null @@ -1,3 +0,0 @@ -#spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false -#spring.datasource.username=user -#spring.datasource.password=password diff --git a/simple/src/main/resources/data.sql b/simple/src/main/resources/data.sql deleted file mode 100644 index ceb5374..0000000 --- a/simple/src/main/resources/data.sql +++ /dev/null @@ -1,5 +0,0 @@ -delete from customer; -insert into customer values (null, "Joe", 88); -insert into customer values (null, "Jack", 54); -insert into customer values (null, "Ann", 32); - diff --git a/simple/src/main/resources/schema.sql b/simple/src/main/resources/schema.sql deleted file mode 100644 index adf9c9c..0000000 --- a/simple/src/main/resources/schema.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE TABLE IF NOT EXISTS `customer` ( `CUST_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(100) NOT NULL, `AGE` int(10) unsigned NOT NULL, PRIMARY KEY (`CUST_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; diff --git a/simple/src/test/java/com/example/SpringSampleAppApplicationTests.java b/simple/src/test/java/com/example/SpringSampleAppApplicationTests.java deleted file mode 100644 index 3ed3863..0000000 --- a/simple/src/test/java/com/example/SpringSampleAppApplicationTests.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.example; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class SpringSampleAppApplicationTests { - - @Test - public void contextLoads() { - } - -} diff --git a/2tier/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java similarity index 100% rename from 2tier/src/main/java/com/example/SpringSampleAppApplication.java rename to src/main/java/com/example/SpringSampleAppApplication.java diff --git a/2tier/src/main/resources/data-hsqldb.sql b/src/main/resources/data-hsqldb.sql similarity index 100% rename from 2tier/src/main/resources/data-hsqldb.sql rename to src/main/resources/data-hsqldb.sql diff --git a/2tier/src/main/resources/data-mysql.sql b/src/main/resources/data-mysql.sql similarity index 100% rename from 2tier/src/main/resources/data-mysql.sql rename to src/main/resources/data-mysql.sql diff --git a/2tier/src/main/resources/data-postgresql.sql b/src/main/resources/data-postgresql.sql similarity index 100% rename from 2tier/src/main/resources/data-postgresql.sql rename to src/main/resources/data-postgresql.sql diff --git a/2tier/src/main/resources/schema-hsqldb.sql b/src/main/resources/schema-hsqldb.sql similarity index 100% rename from 2tier/src/main/resources/schema-hsqldb.sql rename to src/main/resources/schema-hsqldb.sql diff --git a/2tier/src/main/resources/schema-mysql.sql b/src/main/resources/schema-mysql.sql similarity index 100% rename from 2tier/src/main/resources/schema-mysql.sql rename to src/main/resources/schema-mysql.sql diff --git a/2tier/src/main/resources/schema-postgresql.sql b/src/main/resources/schema-postgresql.sql similarity index 100% rename from 2tier/src/main/resources/schema-postgresql.sql rename to src/main/resources/schema-postgresql.sql diff --git a/2tier/src/test/java/com/example/SpringSampleAppApplicationTests.java b/src/test/java/com/example/SpringSampleAppApplicationTests.java similarity index 100% rename from 2tier/src/test/java/com/example/SpringSampleAppApplicationTests.java rename to src/test/java/com/example/SpringSampleAppApplicationTests.java From b11dc6d4e0bee0ee29d9a63a5dcc125e1c292633 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 17 Nov 2016 17:13:15 -0500 Subject: [PATCH 59/68] added lastnames matching databases for ease --- src/main/resources/data-hsqldb.sql | 6 +++--- src/main/resources/data-mysql.sql | 6 +++--- src/main/resources/data-postgresql.sql | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/resources/data-hsqldb.sql b/src/main/resources/data-hsqldb.sql index 21208ba..ea6e18a 100644 --- a/src/main/resources/data-hsqldb.sql +++ b/src/main/resources/data-hsqldb.sql @@ -1,5 +1,5 @@ delete from customer; -insert into customer (name, age) values ('Joe', 88); -insert into customer (name, age) values ('Jack', 54); -insert into customer (name, age) values ('Ann', 32); +insert into customer (name, age) values ('Joe Hsql', 88); +insert into customer (name, age) values ('Jack Hsql', 54); +insert into customer (name, age) values ('Ann Hsql', 32); diff --git a/src/main/resources/data-mysql.sql b/src/main/resources/data-mysql.sql index ceb5374..87c3dc5 100644 --- a/src/main/resources/data-mysql.sql +++ b/src/main/resources/data-mysql.sql @@ -1,5 +1,5 @@ delete from customer; -insert into customer values (null, "Joe", 88); -insert into customer values (null, "Jack", 54); -insert into customer values (null, "Ann", 32); +insert into customer values (null, "Joe Mysql", 88); +insert into customer values (null, "Jack Mysql", 54); +insert into customer values (null, "Ann Mysql", 32); diff --git a/src/main/resources/data-postgresql.sql b/src/main/resources/data-postgresql.sql index 40d0dd0..931d2dc 100644 --- a/src/main/resources/data-postgresql.sql +++ b/src/main/resources/data-postgresql.sql @@ -1,5 +1,5 @@ delete from customer; -insert into customer (name,age) values ('Joe', 88); -insert into customer (name,age) values ('Jack', 54); -insert into customer (name,age) values ('Ann', 32); +insert into customer (name,age) values ('Joe Psql', 88); +insert into customer (name,age) values ('Jack Psql', 54); +insert into customer (name,age) values ('Ann Psql', 32); From fdb081cf4cdb16190a2ad2912e441c1f69ecc1b1 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Mon, 28 Aug 2017 19:48:32 +0000 Subject: [PATCH 60/68] Adding pipeline --- Jenkinsfile | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++ pom.xml | 32 ++++++++++++++++---- 2 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..00aa6bf --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,86 @@ +#!/usr/bin/groovy +@Library('github.com/fabric8io/fabric8-pipeline-library@master') + +def localItestPattern = "" +try { + localItestPattern = ITEST_PATTERN +} catch (Throwable e) { + localItestPattern = "*IT" +} + +def localFailIfNoTests = "" +try { + localFailIfNoTests = ITEST_FAIL_IF_NO_TEST +} catch (Throwable e) { + localFailIfNoTests = "false" +} + +def versionPrefix = "" +try { + versionPrefix = VERSION_PREFIX +} catch (Throwable e) { + versionPrefix = "1.0" +} + +def canaryVersion = "${versionPrefix}.${env.BUILD_NUMBER}" + +def fabric8Console = "${env.FABRIC8_CONSOLE ?: ''}" +def utils = new io.fabric8.Utils() +def label = "buildpod.${env.JOB_NAME}.${env.BUILD_NUMBER}".replace('-', '_').replace('/', '_') +def envStage = utils.environmentNamespace('stage') +def envProd = utils.environmentNamespace('run') +def stashName = "" +def deploy = false +mavenNode { + checkout scm + if (utils.isCI()){ + + mavenCI{} + + } else if (utils.isCD()){ + deploy = true + echo 'NOTE: running pipelines for the first time will take longer as build and base docker images are pulled onto the node' + container(name: 'maven') { + + stage('Build Release'){ + mavenCanaryRelease { + version = canaryVersion + } + } + + stage('Integration Testing'){ + mavenIntegrationTest { + environment = 'Test' + failIfNoTests = localFailIfNoTests + itestPattern = localItestPattern + } + } + + stage('Rollout to Stage'){ + kubernetesApply(environment: envStage) + //stash deployments + stashName = label + stash includes: '**/*.yml', name: stashName + } + } + } +} + +if (deploy){ + node { + stage('Approve'){ + approve { + room = null + version = canaryVersion + console = fabric8Console + environment = 'Stage' + } + } + + stage('Rollout to Run'){ + unstash stashName + kubernetesApply(environment: envProd) + } + } +} + diff --git a/pom.xml b/pom.xml index f22cd83..0dac5c5 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,4 @@ - - + 4.0.0 com.example @@ -93,8 +91,32 @@ org.springframework.boot spring-boot-maven-plugin - + + + io.fabric8 + fabric8-maven-plugin + 3.5.22 + + + + resource + build + + + + + + + + + VeerSpace + + + + + + - + \ No newline at end of file From e38d1102e246c58af8c58174b4e42d12c51edd6a Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Mon, 28 Aug 2017 18:15:26 -0400 Subject: [PATCH 61/68] Delete Jenkinsfile --- Jenkinsfile | 86 ----------------------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 00aa6bf..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/groovy -@Library('github.com/fabric8io/fabric8-pipeline-library@master') - -def localItestPattern = "" -try { - localItestPattern = ITEST_PATTERN -} catch (Throwable e) { - localItestPattern = "*IT" -} - -def localFailIfNoTests = "" -try { - localFailIfNoTests = ITEST_FAIL_IF_NO_TEST -} catch (Throwable e) { - localFailIfNoTests = "false" -} - -def versionPrefix = "" -try { - versionPrefix = VERSION_PREFIX -} catch (Throwable e) { - versionPrefix = "1.0" -} - -def canaryVersion = "${versionPrefix}.${env.BUILD_NUMBER}" - -def fabric8Console = "${env.FABRIC8_CONSOLE ?: ''}" -def utils = new io.fabric8.Utils() -def label = "buildpod.${env.JOB_NAME}.${env.BUILD_NUMBER}".replace('-', '_').replace('/', '_') -def envStage = utils.environmentNamespace('stage') -def envProd = utils.environmentNamespace('run') -def stashName = "" -def deploy = false -mavenNode { - checkout scm - if (utils.isCI()){ - - mavenCI{} - - } else if (utils.isCD()){ - deploy = true - echo 'NOTE: running pipelines for the first time will take longer as build and base docker images are pulled onto the node' - container(name: 'maven') { - - stage('Build Release'){ - mavenCanaryRelease { - version = canaryVersion - } - } - - stage('Integration Testing'){ - mavenIntegrationTest { - environment = 'Test' - failIfNoTests = localFailIfNoTests - itestPattern = localItestPattern - } - } - - stage('Rollout to Stage'){ - kubernetesApply(environment: envStage) - //stash deployments - stashName = label - stash includes: '**/*.yml', name: stashName - } - } - } -} - -if (deploy){ - node { - stage('Approve'){ - approve { - room = null - version = canaryVersion - console = fabric8Console - environment = 'Stage' - } - } - - stage('Rollout to Run'){ - unstash stashName - kubernetesApply(environment: envProd) - } - } -} - From 2c56d8cec2047515d150f962dc571e0e174992f4 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Mon, 28 Aug 2017 22:42:17 +0000 Subject: [PATCH 62/68] Adding pipeline --- Jenkinsfile | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++ pom.xml | 2 +- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..00aa6bf --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,86 @@ +#!/usr/bin/groovy +@Library('github.com/fabric8io/fabric8-pipeline-library@master') + +def localItestPattern = "" +try { + localItestPattern = ITEST_PATTERN +} catch (Throwable e) { + localItestPattern = "*IT" +} + +def localFailIfNoTests = "" +try { + localFailIfNoTests = ITEST_FAIL_IF_NO_TEST +} catch (Throwable e) { + localFailIfNoTests = "false" +} + +def versionPrefix = "" +try { + versionPrefix = VERSION_PREFIX +} catch (Throwable e) { + versionPrefix = "1.0" +} + +def canaryVersion = "${versionPrefix}.${env.BUILD_NUMBER}" + +def fabric8Console = "${env.FABRIC8_CONSOLE ?: ''}" +def utils = new io.fabric8.Utils() +def label = "buildpod.${env.JOB_NAME}.${env.BUILD_NUMBER}".replace('-', '_').replace('/', '_') +def envStage = utils.environmentNamespace('stage') +def envProd = utils.environmentNamespace('run') +def stashName = "" +def deploy = false +mavenNode { + checkout scm + if (utils.isCI()){ + + mavenCI{} + + } else if (utils.isCD()){ + deploy = true + echo 'NOTE: running pipelines for the first time will take longer as build and base docker images are pulled onto the node' + container(name: 'maven') { + + stage('Build Release'){ + mavenCanaryRelease { + version = canaryVersion + } + } + + stage('Integration Testing'){ + mavenIntegrationTest { + environment = 'Test' + failIfNoTests = localFailIfNoTests + itestPattern = localItestPattern + } + } + + stage('Rollout to Stage'){ + kubernetesApply(environment: envStage) + //stash deployments + stashName = label + stash includes: '**/*.yml', name: stashName + } + } + } +} + +if (deploy){ + node { + stage('Approve'){ + approve { + room = null + version = canaryVersion + console = fabric8Console + environment = 'Stage' + } + } + + stage('Rollout to Run'){ + unstash stashName + kubernetesApply(environment: envProd) + } + } +} + diff --git a/pom.xml b/pom.xml index 0dac5c5..df1fc07 100644 --- a/pom.xml +++ b/pom.xml @@ -109,7 +109,7 @@ - VeerSpace + veerspace From 5be3672ee9ddb8d216a1d4f1d7e808db842b72fd Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Mon, 28 Aug 2017 23:11:28 +0000 Subject: [PATCH 63/68] changed the location of application.properties --- .../main/resources/application.properties | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename application.properties => src/main/resources/application.properties (100%) diff --git a/application.properties b/src/main/resources/application.properties similarity index 100% rename from application.properties rename to src/main/resources/application.properties From 87a98fdc5b1e3f2958fe65fdf9527ddfeeaba7a4 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Mon, 28 Aug 2017 23:17:26 +0000 Subject: [PATCH 64/68] edited the location where hsqldb gets created /opt/app-root/src is not working --- src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 43e315e..89fbd36 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,6 +2,6 @@ # url = jdbc:mysql://<>:<>/<>?useSSL=false #spring.datasource.url= jdbc:mysql://mysql:3306/sampledb?useSSL=false spring.datasource.platform=hsqldb -spring.datasource.url= jdbc:hsqldb:file:/opt/app-root/src/mydb;shutdown=true +spring.datasource.url= jdbc:hsqldb:file:database/mydb;shutdown=true spring.datasource.username=user spring.datasource.password=password From 0e92bdc847e74bead8b21db61a056d7b1b11ad10 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 15 Feb 2018 19:59:12 -0500 Subject: [PATCH 65/68] split out live and ready --- .../example/SpringSampleAppApplication.java | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index 04140fb..e6cfefc 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -38,6 +38,7 @@ public static void main(String[] args) { class HomeRestController { boolean healthy=true; + boolean alive=true; String hostname=""; public HomeRestController(){ try { @@ -53,18 +54,40 @@ public String home(){ return "

"+hostname+"

"; } - @RequestMapping("/healthz") - public ResponseEntity healthz(){ + @RequestMapping("/ready") + public ResponseEntity ready(){ if (healthy) return new ResponseEntity(HttpStatus.ACCEPTED); else return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE); } - @RequestMapping("/cancer") - public String cancer(){ + + @RequestMapping("/live") + public ResponseEntity live(){ + if (alive) + return new ResponseEntity(HttpStatus.ACCEPTED); + else + return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE); + } + + @RequestMapping("/suffer") + public String suffer(){ + healthy=false; + return hostname+" is getting Sick "; + } + + @RequestMapping("/medicate") + public String medicate(){ + healthy=true; + return hostname+" is getting Better "; + } + + + @RequestMapping("/kill") + public String suffer(){ healthy=false; - return "Killed "+hostname; + return hostname+" is Dying "; } @Autowired From 03f61432172bc0883eeb0a8de52292bc29c720f8 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 15 Feb 2018 20:06:14 -0500 Subject: [PATCH 66/68] split out live and ready --- src/main/java/com/example/SpringSampleAppApplication.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index e6cfefc..6a52041 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -71,8 +71,8 @@ public ResponseEntity live(){ return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE); } - @RequestMapping("/suffer") - public String suffer(){ + @RequestMapping("/disease") + public String disease(){ healthy=false; return hostname+" is getting Sick "; } From c6954d7697249248c060d6eeddff0222a3c738e9 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 15 Feb 2018 20:53:27 -0500 Subject: [PATCH 67/68] fixed error with kill --- src/main/java/com/example/SpringSampleAppApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index 6a52041..9b5ffa1 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -86,7 +86,7 @@ public String medicate(){ @RequestMapping("/kill") public String suffer(){ - healthy=false; + alive=false; return hostname+" is Dying "; } From 608a340096ee3dd560b68a3e11cdf39348ce5a49 Mon Sep 17 00:00:00 2001 From: VeerMuchandi Date: Thu, 15 Feb 2018 21:19:59 -0500 Subject: [PATCH 68/68] changed method names --- src/main/java/com/example/SpringSampleAppApplication.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/SpringSampleAppApplication.java b/src/main/java/com/example/SpringSampleAppApplication.java index 9b5ffa1..93641ca 100644 --- a/src/main/java/com/example/SpringSampleAppApplication.java +++ b/src/main/java/com/example/SpringSampleAppApplication.java @@ -71,14 +71,14 @@ public ResponseEntity live(){ return new ResponseEntity(HttpStatus.NOT_ACCEPTABLE); } - @RequestMapping("/disease") - public String disease(){ + @RequestMapping("/infect") + public String infect(){ healthy=false; return hostname+" is getting Sick "; } - @RequestMapping("/medicate") - public String medicate(){ + @RequestMapping("/cure") + public String cure(){ healthy=true; return hostname+" is getting Better "; }