You are not logged in.

#1 2010-06-14 04:01:41

StrangeAttractor
Member
From: Prague, CZ
Registered: 2010-06-14
Posts: 54

Can't connect to MySQL from NetBeans

ArchLinux 6.10. NetBeans 6.8. Everything is today-updated. MySQL runs without errors and PhpMyAdmin successfully connects to it. skip-network is off in every my.cnf. -J-Djava.net.preferIPv4Stack=true is set in netbeans.conf. NetBeans reaches its update server as well as local (but over network through localhost) GlassFish-V3 server without problems.

But when I try to add a connection to MySQL in NetBeans says "unable to connect! cannot establish connection to jdbc:mysql://localhost:3306/consult using com.mysql.jdbc.Driver (communications link failure last packet sent to the server was 0ms ago)".

Any guess how to fix this?

Thanks a lot in advance.

Last edited by StrangeAttractor (2010-06-14 04:02:29)

Offline

#2 2010-06-14 04:26:28

foutrelis
Developer
From: Athens, Greece
Registered: 2008-07-28
Posts: 705
Website

Re: Can't connect to MySQL from NetBeans

Is `skip-networking' commented out in /etc/mysql/my.cnf? Also, verify that mysqld is listening on port 3306 with the command `netstat -tln | grep 3306'.

Offline

#3 2010-06-14 04:49:15

StrangeAttractor
Member
From: Prague, CZ
Registered: 2010-06-14
Posts: 54

Re: Can't connect to MySQL from NetBeans

foutrelis wrote:

Is `skip-networking' commented out in /etc/mysql/my.cnf?

Yes, of course, as I've already specified above.

foutrelis wrote:

Also, verify that mysqld is listening on port 3306 with the command `netstat -tln | grep 3306'.

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN

I don't yet know how to interpret this, I've just switched to Arch Linux fom Windows XP less than a week ago.

Last edited by StrangeAttractor (2010-06-14 04:51:43)

Offline

#4 2010-06-14 06:22:43

toffyrn
Member
Registered: 2008-10-07
Posts: 221

Re: Can't connect to MySQL from NetBeans

I do belive you need this:
http://www.mysql.com/downloads/connector/j/

Wich is in the aur:
aur/mysql-jdbc 5.1.12-1 (133)
    The official JDBC driver for MySQL

Offline

#5 2010-06-14 06:34:00

foutrelis
Developer
From: Athens, Greece
Registered: 2008-07-28
Posts: 705
Website

Re: Can't connect to MySQL from NetBeans

StrangeAttractor wrote:

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN

I don't yet know how to interpret this, I've just switched to Arch Linux fom Windows XP less than a week ago.

That means that MySQL is indeed listening for incoming connections on port 3306.

Try toffyrn's suggestion. tongue

Offline

#6 2010-06-15 06:46:12

StrangeAttractor
Member
From: Prague, CZ
Registered: 2010-06-14
Posts: 54

Re: Can't connect to MySQL from NetBeans

toffyrn wrote:

I do belive you need this:
http://www.mysql.com/downloads/connector/j/

Wich is in the aur:
aur/mysql-jdbc 5.1.12-1 (133)
    The official JDBC driver for MySQL

Installed from AUR. Nothing changed. The error (exactly the same) persists.


I believe MySQL JDBC drier is always included by default in the full distribution of either Sun JDK or NetBeans or MySQL as I have never before had to install it separately, the actual error does not say any classes are missing, the MySQL driver appears in the list in NetBeans.

Last edited by StrangeAttractor (2010-06-15 06:46:47)

Offline

#7 2010-06-15 07:07:43

StrangeAttractor
Member
From: Prague, CZ
Registered: 2010-06-14
Posts: 54

Re: Can't connect to MySQL from NetBeans

By the way, I've just tried XAMPP and found NetBeans connecting to XAMPP-bundled MySQL without any problems (which absolutely does not mean the problem is solved - I wouldnt like to give up using normal system-instelled MySQL). This makes me to conclude that the problem is in MySQL. How can that be? As we've found above, MySQL listens on default port. PhpMyAdmin also works without problems as well as command-line mysql, skip-network is off.

Last edited by StrangeAttractor (2010-06-15 07:20:17)

Offline

#8 2010-06-15 08:34:06

foutrelis
Developer
From: Athens, Greece
Registered: 2008-07-28
Posts: 705
Website

Re: Can't connect to MySQL from NetBeans

it appears we got tricked by tcp_wrappers. If you run the `mysql' client with `-h localhost' it will still connect through the socket; to force it use the network, you also have to specify `--protocol=TCP'. If you do that, it'll fail to connect just like Netbeans.

So, you should be able to solve the problem you're facing by learning about tcp_wrappers (`man 5 hosts_access') and then editing /etc/hosts.allow accordingly to allow local connections to the MySQL server (maybe add a line containing `mysqld: LOCAL'.)

Hope this works for you. tongue

Offline

#9 2010-06-15 10:54:34

StrangeAttractor
Member
From: Prague, CZ
Registered: 2010-06-14
Posts: 54

Re: Can't connect to MySQL from NetBeans

foutrelis wrote:

editing /etc/hosts.allow accordingly to allow local connections to the MySQL server (maybe add a line containing `mysqld: LOCAL'.)

Thanks a lot, foutrelis, this has solved the problem.

Offline

#10 2010-07-14 03:10:35

nomorewindows
Member
Registered: 2010-04-03
Posts: 3,408

Re: Can't connect to MySQL from NetBeans

I just commented out the mysqld lines from /etc/hosts.allow & commented out the ALL:ALL lines from /etc/hosts.deny and it worked.  Was the only difference I could find from the Win/MySqld versus the *NIX versions.  I thought that hosts.allow and hosts.deny were standard *NIX demons, but I guess they are part of tcp_wrappers with this distro.  I was not finding anything under the '08S01' error message posts.


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Offline

Board footer

Powered by FluxBB