I am a solution architect, designer and corporate trainer. I have 11 years of experience in java j2ee development and I like designing solution and teaching.

When I am not working; I love spending time with family, watching movies and travelling and exploring new places.


MySql Setup on AWS Cloud

Following are the sequential list of screen shots to setup MySQL DB on AWS and steps to connect to the database from your machine.












Now create Data Base Security Groups to attache to the created DB instance.








Tag It with the name for easy identification.




Now Go back and check the instance. Endpoint is created and status is Available.

Now apply the created security group to this instance.






Data base instance is setup and ready for use. Lets connect to it from your local machine.

vfroot@INMHPUUBUNTU14:~$ mysql

The program ‘mysql’ can be found in the following packages:

* mysql-client-core-5.5

* mariadb-client-core-5.5

* mysql-client-core-5.6

* percona-xtradb-cluster-client-5.5

Try: sudo apt-get install <selected package>

vfroot@INMHPUUBUNTU14:~$ sudo apt-get install mysql-client-core-5.6

Install the mysql client package—>

Now open the terminal and connect to host (-h <host – mysql db instance name>, -u <username> -p <password>)

vfroot@INMHPUUBUNTU14:~$ mysql -h -u waqarsyed23 -p


vfroot@INMHPUUBUNTU14:~$ mysql -h <hostname of the db instance – refer above screens for the same> -u <db user name> -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 25

Server version: 5.6.34-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective


Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show databases;


| Database |


| information_schema |

| innodb |

| mysql |

| pdhcdb |

| performance_schema |


5 rows in set (0.12 sec)

mysql> use pdhcdb;

Database changed

mysql> show tables;

mysql> exit;


Spring Boot With AngularJS Example


Below is the working source code which demonstrate use of AngulaJS with Spring Boot.

“DemoController” returns random data in Map object which is read by Angular JS controller “hello.js” to render it on the “index.html”


public class DemoController {

public Map<String,Object> home() {
Map<String,Object> model = new HashMap<String,Object>();
model.put(“id”, UUID.randomUUID().toString());
model.put(“content”, “Waqar Syed Sample Demo”);
return model;


angular.module('hello', []).controller('home', function($http) {
   var self = this;
   $http.get('resource/').then(function(response) {
      self.greeting =;

<!doctype html>
<title>Spring Boot with AngularJS</title>
<link href="css/angular-bootstrap.css" rel="stylesheet">
<style type="text/css">
[ng\:cloak], [ng-cloak], .ng-cloak {
   display: none !important;
<body ng-app="hello">
   div class="container"
      <h1// Spring Boot With AngularJS Demo</h1>
      div ng-controller="home as home" ng-cloak class="ng-cloak"
        <p>This ID Coming from SpringBoot Controller: {{}}</p>
         <p>Content From Controller- {{home.greeting.content}}</p>
   script src="js/angular-bootstrap.js" type="text/javascript" /script
   script src="js/hello.js" /script


For the purpose of this sample, I am going to use, which is a Java-based tool chain for preprocessing and packaging front end assets. It can be used as a JIT (Just in Time) `Filter` in any Servlet application, but it also has good support for build tools like Maven and Eclipse. So I am going to build static resource files and bundle them in application JAR.

Wro4j is controlled from an XML configuration file that doesn’t know about your build classpath, and only understand absolute file paths, so we have to create an absolute file location and insert it in `wro.xml`. For that purpose we use Maven resource filtering and that is why there is an explicit “maven-resources-plugin” declaration.

Refer to pom.xml for the dependency added as well as wro configuration

Wro4j Source Files

There are only 3 files (and one of those is empty, ready for later customization):
* ‘` is a configuration file for the preprocessing and rendering engine in wro4j.
You can use it to switch on and off various parts of the toolchain. In this case we use it to compile CSS from and to minify JavaScript, ultimately combining the sources from all the libraries we need in two files.
* ‘wro.xml` declares a single “group” of resources called “angular-bootstrap”, and this ends up being the base name of the static resources that are generated. It includes references to `&lt;css&gt;` and `&lt;js&gt;` elements in the webjars we added, and also to a local source file `main.less`.
* `main.less` is empty in the sample code, but could be used to customise the look and feel, changing the default settings in Twitter Bootstrap. E.g. to change the colours from default blue to light pink you could add a single line.


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""


   <description>Demo project for Spring Boot</description>

      <relativePath /> <!-- lookup parent from repository -->









Complete working source code is located below:




Ehcache With SpringBoot Example

This sample example demonstrates use of Ehchache in SpringBoot application.

  1. Source code contains pom.xml file with below required dependencies.
        <artifactId>spring-boot-starter-web</artifactId> <!-- starter for using Spring MVC -->
        <artifactId>spring-boot-starter-cache</artifactId> <!--Starter for using Spring Framework's caching support-->
        <groupId>javax.cache</groupId> <!-- JSR-107 API-->

Cache configuration xml and cache setup class.

2. ehcache.xml


      <jsr107:cache name="personCache" template="heap-cache"/>

  <cache-template name="heap-cache">
      <heap unit="entries">2000</heap>
      <offheap unit="MB">100</offheap> <!-- unit of measure is case sensitive! -->

Java class to setup cache of duration of 20 seconds to the cache elements.

public class CacheSetup implements JCacheManagerCustomizer {
    public void customize(CacheManager cacheManager) {
        cacheManager.createCache("personCache", new MutableConfiguration<>()
                .setExpiryPolicyFactory(TouchedExpiryPolicy.factoryOf(new Duration(SECONDS, 20)))

4. - It loads the ehcache.xml

5. Service class which stores the objects to cache
As seen in below service class; cache names "personCache" is annoted to
this service class and getPerson method output is stored in cache 
for 20 seconds as configured in
@CacheDefaults(cacheName = "personCache")
public class PersonService {
    private static final Logger LOGGER = LoggerFactory.getLogger(PersonService.class);

    public Person getPerson(int persId)
    {"persId " + persId + " not found in cache. TimeStamp: {}", new Date());

        switch (persId)
            case 12345:
                return new Person(persId, "James", "Bond");
            case 6789:
                return new Person(persId, "Spider", "Man");
                return new Person(persId,"Bat","Man");


Please download below source code which contains working sample code:

On Demand Linux t2.micro Instance Hour – AWS unexpected charge

I got the unexpected billing for the service “On Demand Linux t2.micro Instance” usage.

I am using the aws cloud under free tier for which you are eligible of 750 hours per month of free usage.

The free tier for Amazon EC2 provides you with 750 hours usage of Linux (any combination oft2.micro and t1.micro instances), plus 750 hours usage of Windows (any combination of t2.micro andt1.micro instances). How you divide this allotment is up to you. For example, you can use one Linux instance continuously for a month, or 10 Linux instances for 75 hours a month

I had only one instance running but got the bill which says – “$0.015 per On Demand Linux t2.micro Instance Hour”

I logged in to my account and find out that I had setup one more instance in another region which I forgot about and hence the bill.

I had setup an instance in Asia Pacific Mumbai and was using it but then there was another instance running in US West Oregon Region

you need to check if by mistake you have launched another instance in another region which you forgot.

Also you need to make sure that auto scaling is not active else your terminated instance will be launched automatically.
You can follow the below link to terminate your unused instaces to avoid unexpected charges