ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long on connect to MySQL












6















When connecting to MySQL, I get an error (see below).



Click here for code



I get this output:



run:
Now connecting to databse...

java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
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.<init>(ConnectionImpl.java:822)
at com.mysql.jdbc.JDBC4Connection.<init>(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 dbms_basic.Dbms_Basic.main(Dbms_Basic.java:28)
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
BUILD SUCCESSFUL (total time: 0 seconds)


How can I solve this?










share|improve this question

























  • Moreover your link to code shows some other error and you have posted something different.

    – niks
    Sep 9 '17 at 14:43











  • that is not actual error.

    – Prashant Priyadarshi
    Sep 9 '17 at 15:05
















6















When connecting to MySQL, I get an error (see below).



Click here for code



I get this output:



run:
Now connecting to databse...

java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
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.<init>(ConnectionImpl.java:822)
at com.mysql.jdbc.JDBC4Connection.<init>(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 dbms_basic.Dbms_Basic.main(Dbms_Basic.java:28)
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
BUILD SUCCESSFUL (total time: 0 seconds)


How can I solve this?










share|improve this question

























  • Moreover your link to code shows some other error and you have posted something different.

    – niks
    Sep 9 '17 at 14:43











  • that is not actual error.

    – Prashant Priyadarshi
    Sep 9 '17 at 15:05














6












6








6


1






When connecting to MySQL, I get an error (see below).



Click here for code



I get this output:



run:
Now connecting to databse...

java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
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.<init>(ConnectionImpl.java:822)
at com.mysql.jdbc.JDBC4Connection.<init>(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 dbms_basic.Dbms_Basic.main(Dbms_Basic.java:28)
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
BUILD SUCCESSFUL (total time: 0 seconds)


How can I solve this?










share|improve this question
















When connecting to MySQL, I get an error (see below).



Click here for code



I get this output:



run:
Now connecting to databse...

java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
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.<init>(ConnectionImpl.java:822)
at com.mysql.jdbc.JDBC4Connection.<init>(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 dbms_basic.Dbms_Basic.main(Dbms_Basic.java:28)
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
BUILD SUCCESSFUL (total time: 0 seconds)


How can I solve this?







java mysql jdbc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 1 '18 at 19:17









Mark Rotteveel

60.1k1477120




60.1k1477120










asked Sep 9 '17 at 13:37









Prashant PriyadarshiPrashant Priyadarshi

48115




48115













  • Moreover your link to code shows some other error and you have posted something different.

    – niks
    Sep 9 '17 at 14:43











  • that is not actual error.

    – Prashant Priyadarshi
    Sep 9 '17 at 15:05



















  • Moreover your link to code shows some other error and you have posted something different.

    – niks
    Sep 9 '17 at 14:43











  • that is not actual error.

    – Prashant Priyadarshi
    Sep 9 '17 at 15:05

















Moreover your link to code shows some other error and you have posted something different.

– niks
Sep 9 '17 at 14:43





Moreover your link to code shows some other error and you have posted something different.

– niks
Sep 9 '17 at 14:43













that is not actual error.

– Prashant Priyadarshi
Sep 9 '17 at 15:05





that is not actual error.

– Prashant Priyadarshi
Sep 9 '17 at 15:05












1 Answer
1






active

oldest

votes


















15














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.






share|improve this answer





















  • 2





    thanks.. by changing connector.. it's working..

    – Prashant Priyadarshi
    Sep 9 '17 at 16:44






  • 1





    Bug#13958793 was already logged and resolved around this on mysql connector.

    – Rizwan
    Sep 9 '17 at 16:45






  • 4





    changed connector's jar version from 5.1.21 to 5.1.45 - worked!

    – Kirill Starostin
    May 2 '18 at 10:07











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46131295%2fclasscastexception-java-math-biginteger-cannot-be-cast-to-java-lang-long-on-con%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









15














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.






share|improve this answer





















  • 2





    thanks.. by changing connector.. it's working..

    – Prashant Priyadarshi
    Sep 9 '17 at 16:44






  • 1





    Bug#13958793 was already logged and resolved around this on mysql connector.

    – Rizwan
    Sep 9 '17 at 16:45






  • 4





    changed connector's jar version from 5.1.21 to 5.1.45 - worked!

    – Kirill Starostin
    May 2 '18 at 10:07
















15














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.






share|improve this answer





















  • 2





    thanks.. by changing connector.. it's working..

    – Prashant Priyadarshi
    Sep 9 '17 at 16:44






  • 1





    Bug#13958793 was already logged and resolved around this on mysql connector.

    – Rizwan
    Sep 9 '17 at 16:45






  • 4





    changed connector's jar version from 5.1.21 to 5.1.45 - worked!

    – Kirill Starostin
    May 2 '18 at 10:07














15












15








15







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.






share|improve this answer















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.







share|improve this answer














share|improve this answer



share|improve this answer








edited Oct 1 '18 at 18:51









Mark Rotteveel

60.1k1477120




60.1k1477120










answered Sep 9 '17 at 16:28









RizwanRizwan

1,250921




1,250921








  • 2





    thanks.. by changing connector.. it's working..

    – Prashant Priyadarshi
    Sep 9 '17 at 16:44






  • 1





    Bug#13958793 was already logged and resolved around this on mysql connector.

    – Rizwan
    Sep 9 '17 at 16:45






  • 4





    changed connector's jar version from 5.1.21 to 5.1.45 - worked!

    – Kirill Starostin
    May 2 '18 at 10:07














  • 2





    thanks.. by changing connector.. it's working..

    – Prashant Priyadarshi
    Sep 9 '17 at 16:44






  • 1





    Bug#13958793 was already logged and resolved around this on mysql connector.

    – Rizwan
    Sep 9 '17 at 16:45






  • 4





    changed connector's jar version from 5.1.21 to 5.1.45 - worked!

    – Kirill Starostin
    May 2 '18 at 10:07








2




2





thanks.. by changing connector.. it's working..

– Prashant Priyadarshi
Sep 9 '17 at 16:44





thanks.. by changing connector.. it's working..

– Prashant Priyadarshi
Sep 9 '17 at 16:44




1




1





Bug#13958793 was already logged and resolved around this on mysql connector.

– Rizwan
Sep 9 '17 at 16:45





Bug#13958793 was already logged and resolved around this on mysql connector.

– Rizwan
Sep 9 '17 at 16:45




4




4





changed connector's jar version from 5.1.21 to 5.1.45 - worked!

– Kirill Starostin
May 2 '18 at 10:07





changed connector's jar version from 5.1.21 to 5.1.45 - worked!

– Kirill Starostin
May 2 '18 at 10:07


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46131295%2fclasscastexception-java-math-biginteger-cannot-be-cast-to-java-lang-long-on-con%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas