title: spring boot + JPA + mysql, unable to retrieve result set
body: <p>i am new to spring boot, having basic knowledge of java. i am trying to build a micro-service to retrieve data from mySQL database. below are the code details.</p>
  
  <p>i am able to retrieve data from the same table using standalone JDBC class. request to help.</p>
  
  <p><strong>- Entity class</strong></p>
  
  <pre><code>package com.studentProject.entity;
  import java.io.Serializable;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.Table;
  import org.springframework.stereotype.Component;
  
  @Entity
  @Component
  @Table(name="students", schema="test_schema")
  public class StudentEntity implements Serializable{
  private static final long serialVersionUID = 1L;
  
  @Id
  @GeneratedValue
  @Column(name="id")
  private Integer id;
  
  @Column(name="name")
  private String name;
  
  @Column(name="course")
  private String course;
  
  @Column(name="country")
  private String country;
  
  @Column(name="phone")
  private String phone;
  
  public StudentEntity(Integer id, String name, String course, String country, String phone) {
      super();
      this.id = id;
      this.name = name;
      this.course = course;
      this.country = country;
      this.phone = phone;
  }
  
  public StudentEntity() {
      super();
      // TODO Auto-generated constructor stub
  }
  
  public Integer getId() {
      return id;
  }
  public void setId(Integer id) {
      this.id = id;
  }
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  public String getCourse() {
      return course;
  }
  
  public void setCourse(String course) {
      this.course = course;
  }
  
  public String getCountry() {
      return country;
  }
  
  public void setCountry(String country) {
      this.country = country;
  }
  
  public String getPhone() {
      return phone;
  }
  
  public void setPhone(String phone) {
      this.phone = phone;
  }
  }
  </code></pre>
  
  <p><strong>-Repository Class</strong></p>
  
  <pre><code>package com.studentProject.repository;
  
  import org.springframework.data.repository.CrudRepository;
  
  import org.springframework.stereotype.Repository;
  
  import com.studentProject.entity.StudentEntity;
  
  @Repository 
  
  public interface StudentRepository extends CrudRepository&lt;StudentEntity, Integer&gt; {
  
  StudentEntity findByName(String name); 
  
  StudentEntity findByCourse(String course);
  
  }
  </code></pre>
  
  <p><strong>-Controller class</strong></p>
  
  <pre><code>package com.studentProject.controller;
  
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Optional;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.bind.annotation.RestController;
  
  import com.studentProject.entity.StudentEntity;
  import com.studentProject.repository.StudentRepository;
  
  @RestController
  public class StudentController {
  
  
      @Autowired
      private StudentRepository studentRepository;
  
      @Autowired
      List&lt;StudentEntity&gt; studentList;
  
      public StudentController(StudentRepository studentRepository, StudentEntity studentEntity,
              List&lt;StudentEntity&gt; studentList) {
          super();
          this.studentRepository = studentRepository;
          this.studentList = studentList;
      }
  
      @GetMapping("/getStudentDetails")
      public Iterable&lt;StudentEntity&gt; getAllStudents(){
  
          return studentRepository.findAll();
      }
  
      @GetMapping("/getStudentDetails/getByName")
      public StudentEntity findByName(@RequestParam(value="name") String name) {
  
          return studentRepository.findByName(name);
      }
  
      @GetMapping("/getStudentDetails/getById/{id}")
      public Optional&lt;StudentEntity&gt; findById(@PathVariable(value="id") Integer id) {
  
          return studentRepository.findById(id);
      }
  
      @GetMapping("/getStudentDetails/welcome")
      public String welcome() {
  
          return "hi brother welcome";
      }
      }
  </code></pre>
  
  <p><strong>-Properties File</strong></p>
  
  <pre><code>server.port = 8080
  spring.datasource.driver-class-name = com.mysql.cj.jdbc.Driver
  spring.datasource.url = jdbc:mysql://localhost:3306/
  spring.datasource.username = root
  spring.datasource.password = root
  spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
  spring.data.jpa.repositories.enabled=true
  spring.jpa.show-sql = true
  spring.jpa.hibernate.ddl-auto = none
  spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
  </code></pre>
  
  <p><strong>--Pom.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.1.1.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.StudentProject&lt;/groupId&gt;
      &lt;artifactId&gt;StudentProject-1&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;StudentProject-1&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-rest&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
              &lt;artifactId&gt;lombok&lt;/artifactId&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>-main application</strong></p>
  
  <pre><code>package com.studentProject;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class StudentProject1Application {
  
      public static void main(String[] args) {
          SpringApplication.run(StudentProject1Application.class, args);
      }
  
  }
  </code></pre>
  
  <p>-mysql table details
  schema=<strong>test_schema</strong> and table=<strong>students</strong></p>
  
  <p><strong>error details</strong></p>