title: java.lang.ClassCastException: class com.mysql.cj.jdbc.ConnectionImpl cannot be cast to
body: <p>I am trying to set up micro service for my school project.
  I am using java spring boot framework. 
  But when i compile and run the DB connnection it gave me the error:
  java.lang.ClassCastException: class com.mysql.cj.jdbc.ConnectionImpl cannot be cast to class com.hrms.employees.db.Connection (com.mysql.cj.jdbc.ConnectionImpl and com.hrms.employees.db.Connection are in unnamed module of loader 'app')</p>
  
  <pre><code>package com.hrms.employees.db;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  
  public class Connection {
      private static Connection conn;
  
      static{
          try {
              Class.forName("com.mysql.jdbc.Driver");
              conn = (Connection) DriverManager.getConnection("jdbc:mysql://itsatest2.c45g5gg8tx2m.ap-southeast-1.rds.amazonaws.com","admin","zx55774463");
              System.out.println("connected");
          }
          catch(ClassNotFoundException | SQLException e){
              System.out.println(e.getMessage());
          }
      }
  
      public static Connection getConnection(){
          return conn;
      }
  
  }
  </code></pre>
  
  <p>dependency in grade.build</p>
  
  <pre><code>dependencies {
      implementation 'org.springframework.boot:spring-boot-starter-web'
      testImplementation 'org.springframework.boot:spring-boot-starter-test'
      compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.15'
  }
  </code></pre>
  
  <p>I expect the output string of "connected"</p>