0

I'm trying to connect with MySQL Server using Netbeans, but once I got an error about denied access for user 'root', another time (when I use the password), Netbeans telling me:

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

I'm also using MySQL Workbench, so I know my server is working, but Netbeans can't establish a connection with it. Versions of programs I'm using:
MySQL Server 8.0
MySQL Workbench 6.3 CE
NetBeans 8.2
Driver files I tried:
5.1.23, 5.1.46, 5.1.45 - provided by NetBeans with names (mysql-connector-java-[version number]-bin.jar
8.0.11 - provided by MySQL with path C:\Program Files (x86)\ Connector J 8.0\mysql-connector-java-8.0.11.jar
OS: Windows 10 x64

Pics: without using password (in MySQL Workbench I don't need to use password

with using password

  • Which NetBeans version do you use and which MySQL JDBC version do you use? – funfried Jul 25 '18 at 13:42
  • NetBeans is 8.2, and JDBC is Connector? If that's it I tried 5.1.23, 5.1.45, 5.1.46 and 8.0.11 – Patryk Niklewicz Jul 25 '18 at 14:13
  • Yes, JDBC == Connector :) Do you have the same issues (java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long) with 8.0.11 than with some of the 5.x versions? Which version of MySQL server do you use? – funfried Jul 25 '18 at 14:18
  • I'm using MySQL Server 8.0.11, and yes, with every version I mentioned before – Patryk Niklewicz Jul 25 '18 at 14:32
  • Post the code. BigInteger plays no part in connecting to anything. That's more likely from a query of yours. – duffymo Jul 25 '18 at 16:50
  • and there is a problem, because I don't have any code yet, I've just set a server and wanted to start anything, but for now I can't – Patryk Niklewicz Jul 25 '18 at 17:17
  • 1
    You need to provide far more information. Update your post with all of the following : [1] The version of MySQL. [2] The name of the driver file (i.e. your Connector/J jar file) being used. [3] Your version of NetBeans [4] The JDK being used. [5] Your O/S. [6] Your version of MySQL Workbench. [MySQL Workbench 8.0.11 rc](https://dev.mysql.com/downloads/workbench/8.0.html) is the latest. [7] A screen shot showing exactly what you were doing when you got the ClassCastException in NetBeans. – skomisa Jul 26 '18 at 05:55
  • @PatrykNiklewicz Try this: [1] In the **Services** panel select your MySQL driver node (**Databases > Drivers > MySQL (Connector/J driver)**, [2] Right click and select **Connect Using...** [3] Remove **?zeroDateTimeBehavior=convertToNull** from the end of your **JDBC URL** connection string [4] Click the **Test Connection** button .....Do you get *Connection Succeeded*, or an error message? – skomisa Jul 26 '18 at 16:43
  • @PatrykNiklewicz Also, if connection fails, since you have been switching drivers: [1] Right-click the driver node and select **Customize**. [2] Verify that the **Driver File(s)** field contains the full path of your **mysql-connector-java-8.0.11.jar** file, and nothing else. – skomisa Jul 26 '18 at 16:48
  • @PatrykNiklewicz Also, if possible, consider upgrading to [MySQL Workbench 8.0.11 rc](https://dev.mysql.com/downloads/workbench/8.0.html). – skomisa Jul 26 '18 at 16:52
  • I also tried that, someone wrote about that solution here on stack, but even with this I'm getting the same error https://imgur.com/a/2fzHIrb – Patryk Niklewicz Jul 26 '18 at 16:57
  • @skomisa here are pahts to connectors: https://imgur.com/a/LqR30WX also upgrading MySQL Workbench didn't changed anything, maybe this is something wrong with server? – Patryk Niklewicz Jul 26 '18 at 17:26
  • @PatrykNiklewicz [1] Using **Customize**, remove all files except the **connector-java-8.0.11.jar** file from the **Driver File(s)** field [2] Using **Connect Using...**, remove **?zeroDateTimeBehavior=convertToNull** from the end of your **JDBC URL** connection string, enter the password for root, and then click **Test Connection**. ....What is the response when you click that button now? – skomisa Jul 26 '18 at 17:37
  • @skomisa thanks, maybe there was a problem with to many jdbc connectors added, but now I'm getting error: Cannot establish a connection to jdbc:mysql://localhost:3306/mysql using com.mysql.jdbc.Driver (The server time zone value 'rodkowoeuropejski czas letni' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.) – Patryk Niklewicz Jul 26 '18 at 17:46
  • @PatrykNiklewicz OK. You could try specifying your timezone in the connection string (see https://stackoverflow.com/a/27276523/2985643 for a possible solution). But if that doesn't work I think you should create a new question on SO because that problem is qualitatively different to your original issue here (i.e. ClassCastException), and I'm assuming that is now resolved. – skomisa Jul 26 '18 at 18:01

1 Answers1

0

Please check this link, it seems this error appears when you don't have the jdbc driver in the classpath. You have to add the jdbc connector jar to NetBeans by going to the "Services" window, expand "Databases", expand "Drivers" and right-click on "MySQL (Connector/J driver)", choose "Customize" there and click the "Add" button in the dialog, navigate to the jdbc connector and add it, afterwards hit the "Find" button of the "Driver Class" field and then choose the correct class name, hit "Ok" and make another right-click on "MySQL (Connector/J driver)" and choose "Connect Using..." and type in your connection settings.

I hope this helps.

funfried
  • 605
  • 3
  • 14
  • I tried this with every added version of connector, and unfortunately none of them made any difference. It's still "access denied" when I leave password field empty and java.lang.ClassCastException when I'm typing password – Patryk Niklewicz Jul 26 '18 at 11:11
  • Did you also try without `?zeroDateTimeBehavior=convertToNull`? – funfried Jul 26 '18 at 14:59
  • Can you provide a screenshot of the driver customisation dialog? ("Databases" -> "Drivers" -> "MySQL (Connector/J driver)" -> right-click -> "Customize") – funfried Jul 26 '18 at 15:20
  • 1
    @PatrykNiklewicz Remove all the drivers except the one ending with "...8.0.11.jar" from **Driver File(s)**. You only want a single entry in that **Driver File(s)** field. – skomisa Jul 26 '18 at 16:57