ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long on connect to MySQL
Your error clearly says casting is not possible, because a java.math.BigInteger class instance is not an instance of java.lang.Long class.
Now the question arises who is doing casting at what level, when we ask the JDBC driver to make a connection, it is doing lot of work behind the scene before it actually give us back the proper working object of connection.
The problem seems with your version of MySQL in combination with your version of mysql-connector.jar. Try a newer version of MySQL Connector/J (see https://dev.mysql.com/downloads/connector/j/ for the latest version), for example upgrade to 5.1.47 or 8.0.12 if you are using an older version.
my sql :java.math.BigInteger cannot be cast to java.lang.Long
Judging by the syntax, the query that you wrote is wrong. You can check the insert statement format here. So basically what you should write is something in the line of:
insert into login.tables (user_id, password) values("some_user", "s3cr3t")
instead, it seems that you are not listing the column names
first, then assigning the values
, but putting the username value in the column names
space and the password in the values
part.
java.math.BigInteger cannot be cast to java.lang.Integer
You can use:
Integer grandChildCount = ((BigInteger) result[1]).intValue();
Or perhaps cast to Number
to cover both Integer
and BigInteger
values.
Related Topics
The Import Org.Junit Cannot Be Resolved
Maven Clean Issue - Non-Resolvable Import Pom - Could Not Transfer Artifact from Nexus
How to Disable Spring Security for Particular Url
How to Center Crop a Background Image of Linear Layout
How to Count the Rows in Hibernate Query Language
How to Apply Spring Boot Filter Based on Url Pattern
Avoid Keycloak Default Login Page and Use Project Login Page
@Notnull:Validation Custom Message Not Displaying
Java Program to Check for Similar Digits
Java Generics Incompatible Types (No Instance(S) of Type Variable(S) Exist)
How to Create Comma Separated String in Single Quotes from Arraylist of String in Java
Time Complexity of Hashmap Methods
Java Program to Find Palindrome Numbers in Given Range
Ora-00942 Sqlexception With Hibernate (Unable to Find a Table)
Making a Mocked Method Return an Argument That Was Passed to It
Kafka: Failed to Update Metadata After 60000 Ms
How to Update a Jsf Component from a Jsf Backing Bean Method
How to Externalize Application.Properties in Tomcat Webserver for Spring