Java 连接 Netbeans 和 MySQL,但出现 Big Integer 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50029588/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 23:23:37  来源:igfitidea点击:

Connecting Netbeans and MySQL but getting Big Integer error

javamysqlnetbeans

提问by ?rem Nur Ar?

So I am trying to add new connection to my Netbeans' database which is MySQL but I am getting Big Integer casting error can someone please help me? In detail:

所以我正在尝试向我的 Netbeans 的 MySQL 数据库添加新连接,但是我遇到了 Big Integer 转换错误,有人可以帮助我吗?详细:

I right click on existing MySQL Server at localhost:3306 [root(disconnected)>> select connectand this pops up

在 localhost:3306 [root(disconnected)>> 选择connect上右键单击现有的MySQL 服务器,这会弹出



Unable to connect to the MySQL server:

无法连接到 MySQL 服务器:

org.netbeans.api.db.explorer.DatabaseException: org.netbeans.api.db.explorer.DatabaseException: java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long.

org.netbeans.api.db.explorer.DatabaseException: org.netbeans.api.db.explorer.DatabaseException: java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger 不能转换为 java.lang.Long .

The server may not be running or your MySQL connection properties may not be set correctly. Do you want to edit your MySQL connection properties?

服务器可能没有运行,或者您的 MySQL 连接属性可能没有正确设置。你想编辑你的 MySQL 连接属性吗?



And my basic and admin properties are OK.

我的基本和管理属性还可以。

And I tried this too: Right click on databases>> select New Connection>> Driver: MySQL(Connector/J driver), JDBC URL: jdbc:mysql://localhost:3306/mysql, but when I test the connection it gives me the same error.

我也试过这个:右键单击数据库>>选择新连接>>驱动程序:MySQL(连接器/J驱动程序),JDBC URL:jdbc:mysql://localhost:3306/mysql,但是当我测试连接时它给出我同样的错误。

**MySQL server is running.

**MySQL 服务器正在运行。

Thank you.

谢谢你。

回答by Victor

What is the version of your MySQL driver and your MySQL? If you want to use MySQL 8, for example, you could try to use a MySQL driver which supports MySQL 8.

您的 MySQL 驱动程序和 MySQL 的版本是什么?例如,如果您想使用 MySQL 8,您可以尝试使用支持 MySQL 8 的 MySQL 驱动程序。

Try updating your mysql driver.

尝试更新您的mysql 驱动程序

To install the driver:

要安装驱动程序:

1° Go to the services tab, just after databases.

1° 转到服务选项卡,就在数据库之后。

2° Right click on the drivers folder and select add new driver.

2° 右键单击​​驱动程序文件夹并选择添加新驱动程序。

3° Click add and look for the .jar of the driver you downloaded.

3° 单击添加并查找您下载的驱动程序的 .jar。

回答by diddie dee

This is a JDBC Driver problem

这是 JDBC 驱动程序问题

I had a similar problem in netbeans. I resolved by removing the default driver (Connector/J driver) from the driver list under databases/drivers as shown below.

我在 netbeans 中遇到了类似的问题。我通过从数据库/驱动程序下的驱动程序列表中删除默认驱动程序(连接器/J 驱动程序)来解决,如下所示。

This happened with jdbc v8.0.12 on mysql v8.0

这发生在 mysql v8.0 上的 jdbc v8.0.12

enter image description here

在此处输入图片说明

So after removing the default jdbc driver, I add an old version of the driver mysql-connector-java-5.1.47. The connection the succeeded.

所以去掉默认的jdbc驱动后,我添加了一个旧版本的驱动mysql-connector-java-5.1.47。 连接成功。

enter image description here

在此处输入图片说明

回答by Udith Indrakantha

  1. Remove and clean the jdbc connector jar files already come with netbeans.
  2. Add a new connector jar file to the jdbc library.
    (You can download ==> mysql-connector-java/8.0.11
  3. Try again, connection is going to be ok now.
  1. 删除并清理 netbeans 附带的 jdbc 连接器 jar 文件。
  2. 将新的连接器 jar 文件添加到 jdbc 库。
    (可以下载==> mysql-connector-java/8.0.11
  3. 再试一次,现在连接正常了。