title: java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
body: <p>I was trying to connect a database to my Java program and 
  I get the error</p>
  
  <pre><code>May 28, 2018 9:26:40 PM com.example.test main
  SEVERE: null
  java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
      at com.mysql.jdbc.ConnectionImpl.buildCollationMapping(ConnectionImpl.java:1062)
      at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3556)
      at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2513)
      at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2283)
      at com.mysql.jdbc.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:822)
      at com.mysql.jdbc.JDBC4Connection.&lt;init&gt;(JDBC4Connection.java:47)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
      at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:404)
      at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:317)
      at java.sql.DriverManager.getConnection(DriverManager.java:664)
      at java.sql.DriverManager.getConnection(DriverManager.java:247)
      at com.example.test.main(test.java:13)
  Caused by: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
      at com.mysql.jdbc.ConnectionImpl.buildCollationMapping(ConnectionImpl.java:1007)
      ... 15 more cast to java.lang.Long
  </code></pre>
  
  <p>my code is:</p>
  
  <pre><code>package com.example;
  
  import java.sql.*;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  public class test {
  
      public static void main(String[] args) {
  
          try {
              Class.forName("com.mysql.jdbc.Driver");
              Connection c;
              c = DriverManager.getConnection("jdbc:mysql://localhost:3306/company", "root", "root");
              c.close();
          } catch (ClassNotFoundException | SQLException ex) {
              Logger.getLogger(test.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
  }
  </code></pre>
  
  <p>I tried doing everything and could not find a solution. Thanks in advance for helping.</p>
  
  <p><a href="https://i.stack.imgur.com/hfpqZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hfpqZ.png" alt="enter image description here"></a></p>