"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Why am I getting a \"java.math.BigInteger cannot be cast to java.lang.Long\" error when connecting to MySQL?

Why am I getting a \"java.math.BigInteger cannot be cast to java.lang.Long\" error when connecting to MySQL?

Published on 2024-11-12
Browse:668

Why am I getting a \

ClassCastException: java.math.BigInteger Cannot Be Cast to java.lang.Long When Connecting to MySQL

When attempting to connect to a MySQL database, you may encounter an error indicating a casting issue: "java.math.BigInteger cannot be cast to java.lang.Long." This error stems from an underlying problem in the conversion process during connection establishment.

The error message implies that the JDBC driver is trying to cast an instance of java.math.BigInteger to an instance of java.lang.Long, which is not possible as these classes are distinct. To resolve this issue, you should consider updating the MySQL Connector/J library to a more recent version.

It is possible that your current version of MySQL and MySQL Connector/J are incompatible. By upgrading to a newer version of Connector/J, such as 5.1.47 or 8.0.12, you may resolve the casting issue. The latest versions of Connector/J can be downloaded from https://dev.mysql.com/downloads/connector/j/.

Once the updated library is installed and configured, the casting error should no longer occur, allowing you to establish a successful connection to the MySQL database.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3