Wednesday, 30 January 2019

Timer and TimerTask Intro V2 | How to schedule a task once or repeated using Timer and TimerTask


Click here to watch on Youtube:
https://www.youtube.com/watch?v=nkGcKAJXyOA&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge:
Timer and TimerTask Intro V2 | How to schedule a task once or repeated using Timer and TimerTask

CleanUpTask.java

import java.util.TimerTask;

public class CleanUpTask extends TimerTask
{
    public void run()
    {
        System.out.println("Clean up files...");
    }
}

EmailTask.java

import java.util.TimerTask;

public class EmailTask extends TimerTask
{
    public void run()
    {
        System.out.println("Send emails..");
    }
}

TimerDemo.java

import java.util.Timer;
import java.util.TimerTask;

public class TimerDemo
{
    public static void main(String[] args) throws InterruptedException
    {

        Timer timer = new Timer();
        TimerTask cleanUpTask = new CleanUpTask();
        TimerTask emailTask = new EmailTask();

        /*
         * One time execution
         */

        timer.schedule(emailTask, 3000);
 
        /*
         * Repeated execution
         */

        timer.schedule(cleanUpTask, 5000, 2000);

        System.out.println("Timer has schedule the tasks...");

    }

}

Output

Timer has schedule the tasks...
Send emails..
Clean up files...
Clean up files...
Clean up files...
Clean up files...
Clean up files...
Clean up files...
Clean up files...
Clean up files...
Clean up files...
Clean up files...
Clean up files...

Click the below link to download the code:
https://sites.google.com/site/javaspringram2019/java_spring_2019/TimerDemo_Task_Intro_V1.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java_Spring_2019/tree/master/Java_2019/TimerDemo_Task_Intro_V1

Bitbucket Link:
https://bitbucket.org/ramram43210/java_spring_2019/src/2db5cd1f4e7d5ab55ad7af886d6164700143c614/Java_2019/TimerDemo_Task_Intro_V1/?at=master

See also:

  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Spring Tutorial
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial
  • Timer and TimerTask Introduction | How to schedule a task once using Timer and TimerTask


    Click here to watch on Youtube:
    https://www.youtube.com/watch?v=j0UdOx1tRzg&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge:
    Timer and TimerTask Introduction | How to schedule a task once using Timer and TimerTask

    Timer and TimerTask Introduction | How to schedule a task once using Timer and TimerTask

    Timer and TimerTask Introduction | How to schedule a task once using Timer and TimerTask

    CleanUpTimerTask.java

    import java.util.TimerTask;

    public class CleanUpTimerTask extends TimerTask
    {
        public void run()
        {
            System.out.println("Clean up files...");
        }
    }

    TimerDemo.java

    import java.util.Date;
    import java.util.Timer;
    import java.util.TimerTask;

    public class TimerDemo
    {
        public static void main(String[] args)
        {

            /*
             * Creating timer task
             */

            TimerTask cleanUpTimerTask = new CleanUpTimerTask();

            /*
             * Creates a new timer. The associated thread does not run as
             * a daemon.
             */

            Timer timer = new Timer();

            Date scheduleDateTime = new Date(System.currentTimeMillis() + 20000);
            System.out.println("scheduleDateTime = " + scheduleDateTime);

            /*
             * Schedules the specified task for execution at the specified
             * time. If the time is in the past, the task is scheduled for
             * immediate execution.
             *
             * Parameters:
             *
             * task - task to be scheduled.
             *
             * time - time at which task is to be executed.
             */

            timer.schedule(cleanUpTimerTask, scheduleDateTime);
            System.out.println("Timer has schedule the -------cleanUpTimerTask...");
        }

    }

    Output:

    scheduleDateTime = Mon Jan 14 10:15:02 IST 2019
    Timer has schedule the -------cleanUpTimerTask...
    Clean up files...

    Refer: 

    https://docs.oracle.com/javase/8/docs/api/index.html?java/util/TimerTask.html

    https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Timer.html

    Click the below link to download the code:
    https://sites.google.com/site/javaspringram2019/java_spring_2019/TimerDemo_Intro.zip?attredirects=0&d=1

    Github Link:
    https://github.com/ramram43210/Java_Spring_2019/tree/master/Java_2019/TimerDemo_Intro

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java_spring_2019/src/2db5cd1f4e7d5ab55ad7af886d6164700143c614/Java_2019/TimerDemo_Intro/?at=master

    See also:

  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Spring Tutorial
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial
  • Spring JdbcTemplate Example | Spring JDBC tutorial | Spring JDBC


    Click here to watch on Youtube:
    https://www.youtube.com/watch?v=Yh6Q3vkHEjk&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge:
    Spring JdbcTemplate Example | Spring JDBC tutorial | Spring JDBC
    Employee.sql

    CREATE DATABASE org_db;


    CREATE TABLE `employee` (
      `EMPLOYEE_ID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
      `NAME` VARCHAR(100) NOT NULL,
      `AGE` INT(10) NOT NULL,
      `SALARY` INT(10) DEFAULT NULL,
      PRIMARY KEY (`EMPLOYEE_ID`)
    ) ENGINE=INNODB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

    pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.ram.core</groupId>
        <artifactId>SpringDemo</artifactId>
        <packaging>jar</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>SpringDemo</name>
        <url>http://maven.apache.org</url>

        <properties>
            <spring.version>5.0.5.RELEASE</spring.version>
        </properties>

        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>3.8.1</version>
                <scope>test</scope>
            </dependency>

            <!-- Spring 5 dependencies -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${spring.version}</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${spring.version}</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>${spring.version}</version>
            </dependency>

            <!-- MySQL database driver -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.11</version>
            </dependency>

        </dependencies>

    </project>

    Employee.java

    package com.ram.employee.model;

    public class Employee
    {
        private int employeeId;
        private String name;
        private int age;
        private int salary;

        public Employee(int employeeId, String name, int age, int salary)
        {
            super();
            this.employeeId = employeeId;
            this.name = name;
            this.age = age;
            this.salary = salary;
        }

        public int getEmployeeId()
        {
            return employeeId;
        }

        public void setEmployeeId(int employeeId)
        {
            this.employeeId = employeeId;
        }

        public String getName()
        {
            return name;
        }

        public void setName(String name)
        {
            this.name = name;
        }

        public int getAge()
        {
            return age;
        }

        public void setAge(int age)
        {
            this.age = age;
        }

        public int getSalary()
        {
            return salary;
        }

        public void setSalary(int salary)
        {
            this.salary = salary;
        }

        @Override
        public String toString()
        {
            return "Employee [employeeId=" + employeeId + ", name=" + name
                    + ", age=" + age + ", salary=" + salary + "]";
        }

    }

    EmployeeDAO.java

    package com.ram.employee.dao;

    import com.ram.employee.model.Employee;

    public interface EmployeeDAO
    {
        public void insert(Employee employee);
    }

    EmployeeDAOImpl.java

    package com.ram.employee.dao.impl;

    import javax.sql.DataSource;

    import org.springframework.jdbc.core.JdbcTemplate;

    import com.ram.employee.dao.EmployeeDAO;
    import com.ram.employee.model.Employee;

    public class EmployeeDAOImpl implements EmployeeDAO
    {

        private JdbcTemplate jdbcTemplate;

        public void setDataSource(DataSource dataSource)
        {
            this.jdbcTemplate = new JdbcTemplate(dataSource);
        }

        public void insert(Employee employee)
        {

            String sql = "INSERT INTO EMPLOYEE "
                    + "(EMPLOYEE_ID, NAME, AGE,SALARY) VALUES (?, ?, ?,?)";

            jdbcTemplate.update(sql,
                    new Object[] { employee.getEmployeeId(),
                            employee.getName(), employee.getAge(),
                            employee.getSalary() });

        }
    }

    applicationContext.xml

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">


        <bean id="dataSource"
            class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="com.mysql.jdbc.Driver" />
            <property name="url" value="jdbc:mysql://localhost:3306/org_db" />
            <property name="username" value="root" />
            <property name="password" value="root" />
        </bean>

        <bean id="employeeDAO" class="com.ram.employee.dao.impl.EmployeeDAOImpl">
            <property name="dataSource" ref="dataSource" />
        </bean>

    </beans>

    App.java

    package com.ram.core;

    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;

    import com.ram.employee.dao.EmployeeDAO;
    import com.ram.employee.model.Employee;

    public class App
    {
        public static void main(String[] args)
        {
            ApplicationContext context = new ClassPathXmlApplicationContext(
                    "applicationContext.xml");

            EmployeeDAO employeeDAO = (EmployeeDAO) context
                    .getBean("employeeDAO");
            Employee employee = new Employee(1, "Peter", 28, 80000);
            employeeDAO.insert(employee);
            System.out.println("Employee record inserted successfully.");
        }
    }

    Output:

    Jan 29, 2019 10:29:43 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
    INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@736e9adb: startup date [Tue Jan 29 10:29:43 IST 2019]; root of context hierarchy
    Jan 29, 2019 10:29:43 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
    Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
    Jan 29, 2019 10:29:44 AM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
    INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
    Tue Jan 29 10:29:45 IST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
    Employee record inserted successfully.

    Click the below link to download the code:
    https://sites.google.com/site/javaspringram2019/java_spring_2019/SpringDemo_JDBCTemplate_Insert.zip?attredirects=0&d=1

    Github Link:
    https://github.com/ramram43210/Java_Spring_2019/tree/master/Spring_2019/SpringDemo_JDBCTemplate_Insert

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java_spring_2019/src/606d9b2d1d46b8a032c31f0c36dbf2fe048707f1/Spring_2019/SpringDemo_JDBCTemplate_Insert/?at=master

    See also:

  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Spring Tutorial
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial
  • Tuesday, 29 January 2019

    What is DataSource? | Spring JDBC tutorial | Spring JDBC


    Click here to watch on Youtube: 
    https://www.youtube.com/watch?v=0Blj-jZ4Xoc&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge: 
    What is DataSource? | Spring JDBC tutorial | Spring JDBC

    What is DataSource? | Spring JDBC tutorial | Spring JDBC

    What is DataSource? | Spring JDBC tutorial | Spring JDBC

    See also:
  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Spring Tutorial
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial
  • Spring JDBC Insert and find example | Spring JDBC tutorial | Spring JDBC


    Click here to watch on Youtube:
    https://www.youtube.com/watch?v=aCuyM5frkEM&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge:
    Spring JDBC Insert and find example | Spring JDBC tutorial | Spring JDBC

    Spring JDBC Insert and find example | Spring JDBC tutorial | Spring JDBC

    Spring JDBC Insert and find example | Spring JDBC tutorial | Spring JDBC

    Spring JDBC Insert and find example | Spring JDBC tutorial | Spring JDBC

    Spring JDBC Insert and find example | Spring JDBC tutorial | Spring JDBC

    Spring JDBC Insert and find example | Spring JDBC tutorial | Spring JDBC
    Employee.sql

    CREATE DATABASE org_db;


    CREATE TABLE `employee` (
      `EMPLOYEE_ID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
      `NAME` VARCHAR(100) NOT NULL,
      `AGE` INT(10) NOT NULL,
      `SALARY` INT(10) DEFAULT NULL,
      PRIMARY KEY (`EMPLOYEE_ID`)
    ) ENGINE=INNODB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

    pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.ram.core</groupId>
        <artifactId>SpringDemo</artifactId>
        <packaging>jar</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>SpringDemo</name>
        <url>http://maven.apache.org</url>

        <properties>
            <spring.version>5.0.5.RELEASE</spring.version>
        </properties>

        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>3.8.1</version>
                <scope>test</scope>
            </dependency>

            <!-- Spring 5 dependencies -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${spring.version}</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${spring.version}</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>${spring.version}</version>
            </dependency>

            <!-- MySQL database driver -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.11</version>
            </dependency>

        </dependencies>

    </project>

    Employee.java

    package com.ram.employee.model;

    public class Employee
    {
        private int employeeId;
        private String name;
        private int age;
        private int salary;

        public Employee(int employeeId, String name, int age, int salary)
        {
            super();
            this.employeeId = employeeId;
            this.name = name;
            this.age = age;
            this.salary = salary;
        }

        public int getEmployeeId()
        {
            return employeeId;
        }

        public void setEmployeeId(int employeeId)
        {
            this.employeeId = employeeId;
        }

        public String getName()
        {
            return name;
        }

        public void setName(String name)
        {
            this.name = name;
        }

        public int getAge()
        {
            return age;
        }

        public void setAge(int age)
        {
            this.age = age;
        }

        public int getSalary()
        {
            return salary;
        }

        public void setSalary(int salary)
        {
            this.salary = salary;
        }

        @Override
        public String toString()
        {
            return "Employee [employeeId=" + employeeId + ", name=" + name
                    + ", age=" + age + ", salary=" + salary + "]";
        }

    }

    EmployeeDAO.java

    package com.ram.employee.dao;

    import com.ram.employee.model.Employee;

    public interface EmployeeDAO
    {
        public void insert(Employee employee);
        public Employee findByEmployeeId(int employeeId);
    }

    EmployeeDAOImpl.java

    package com.ram.employee.dao.impl;

    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;

    import javax.sql.DataSource;

    import com.ram.employee.dao.EmployeeDAO;
    import com.ram.employee.model.Employee;

    public class EmployeeDAOImpl implements EmployeeDAO
    {
        private DataSource dataSource;

        public void setDataSource(DataSource dataSource)
        {
            this.dataSource = dataSource;
        }

        public void insert(Employee employee)
        {

            String sql = "INSERT INTO EMPLOYEE "
                    + "(EMPLOYEE_ID, NAME, AGE,SALARY) VALUES (?, ?, ?,?)";
            Connection conn = null;

            try
            {
                conn = dataSource.getConnection();
                PreparedStatement ps = conn.prepareStatement(sql);
                ps.setInt(1, employee.getEmployeeId());
                ps.setString(2, employee.getName());
                ps.setInt(3, employee.getAge());
                ps.setInt(4, employee.getSalary());
                ps.executeUpdate();
                ps.close();

            }
            catch (SQLException e)
            {
                throw new RuntimeException(e);

            }
            finally
            {
                if (conn != null)
                {
                    try
                    {
                        conn.close();
                    }
                    catch (SQLException e)
                    {
                    }
                }
            }
        }

        public Employee findByEmployeeId(int employeeId)
        {

            String sql = "SELECT * FROM EMPLOYEE WHERE EMPLOYEE_ID = ?";

            Connection conn = null;

            try
            {
                conn = dataSource.getConnection();
                PreparedStatement ps = conn.prepareStatement(sql);
                ps.setInt(1, employeeId);
                Employee employee = null;
                ResultSet rs = ps.executeQuery();
                if (rs.next())
                {
                    employee = new Employee(rs.getInt("EMPLOYEE_ID"),
                            rs.getString("NAME"), rs.getInt("AGE"),
                            rs.getInt("SALARY"));
                }
                rs.close();
                ps.close();
                return employee;
            }
            catch (SQLException e)
            {
                throw new RuntimeException(e);
            }
            finally
            {
                if (conn != null)
                {
                    try
                    {
                        conn.close();
                    }
                    catch (SQLException e)
                    {
                    }
                }
            }
        }

    }

    Spring-Datasource.xml

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">

     
        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="com.mysql.jdbc.Driver" />
            <property name="url" value="jdbc:mysql://localhost:3306/org_db" />
            <property name="username" value="root" />
            <property name="password" value="root" />
        </bean>

    </beans>

    Spring-Employee.xml

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">


        <bean id="employeeDAO" class="com.ram.employee.dao.impl.EmployeeDAOImpl">
            <property name="dataSource" ref="dataSource" />
        </bean>
     
    </beans>

    Spring-Module.xml

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">


        <import resource="database/Spring-Datasource.xml"/>
        <import resource="employee/Spring-Employee.xml"/>
     
    </beans>

    App.java

    package com.ram.core;

    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;

    import com.ram.employee.dao.EmployeeDAO;
    import com.ram.employee.model.Employee;

    public class App
    {
        public static void main(String[] args)
        {
            ApplicationContext context = new ClassPathXmlApplicationContext(
                    "Spring-Module.xml");

            EmployeeDAO employeeDAO = (EmployeeDAO) context
                    .getBean("employeeDAO");
            Employee employee1 = new Employee(1, "Peter", 28, 80000);
            employeeDAO.insert(employee1);

            Employee employee2 = employeeDAO.findByEmployeeId(1);
            System.out.println(employee2);

        }
    }

    Output:

    Jan 26, 2019 10:30:05 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
    INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@35d176f7: startup date [Sat Jan 26 10:30:05 IST 2019]; root of context hierarchy
    Jan 26, 2019 10:30:05 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [Spring-Module.xml]
    Jan 26, 2019 10:30:06 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [database/Spring-Datasource.xml]
    Jan 26, 2019 10:30:06 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [employee/Spring-Employee.xml]
    Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
    Jan 26, 2019 10:30:07 AM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
    INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
    Sat Jan 26 10:30:08 IST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
    Sat Jan 26 10:30:22 IST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
    Employee [employeeId=1, name=Peter, age=28, salary=80000]

    Click the below link to download the code:
    https://sites.google.com/site/javaspringram2019/java_spring_2019/SpringDemo_JDBC_Insert_find.zip?attredirects=0&d=1

    Github Link:
    https://github.com/ramram43210/Java_Spring_2019/tree/master/Spring_2019/SpringDemo_JDBC_Insert_find

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java_spring_2019/src/2db5cd1f4e7d5ab55ad7af886d6164700143c614/Spring_2019/SpringDemo_JDBC_Insert_find/?at=master

    See also:

  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Spring Tutorial
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial