12 messages in com.mysql.lists.javaRe: How force use of TCP/IP instead o...| From | Sent On | Attachments |
|---|---|---|
| Randy Kerber | 02 Oct 2004 13:41 | |
| Rikard Froberg | 02 Oct 2004 17:43 | |
| Paul DuBois | 02 Oct 2004 19:03 | |
| Paul DuBois | 02 Oct 2004 19:04 | |
| Randy Kerber | 02 Oct 2004 23:01 | |
| Randy Kerber | 02 Oct 2004 23:17 | |
| Paul DuBois | 03 Oct 2004 10:29 | |
| Rikard Froberg | 03 Oct 2004 14:08 | |
| Javier Ponce Albendea | 07 Oct 2004 03:05 | |
| Mark Matthews | 07 Oct 2004 05:37 | |
| Javier Ponce Albendea | 07 Oct 2004 06:03 | |
| Mark Matthews | 07 Oct 2004 06:17 |
| Subject: | Re: How force use of TCP/IP instead of sockets in SuSE Linux![]() |
|---|---|
| From: | Paul DuBois (pa...@mysql.com) |
| Date: | 10/03/2004 10:29:12 AM |
| List: | com.mysql.lists.java |
At 23:18 -0700 10/2/04, Randy Kerber wrote:
On Sat, 2004-10-02 at 19:04, Paul DuBois wrote:
At 13:41 -0700 10/2/04, Randy Kerber wrote:
MySQL 4.1.3 beta mysql-connector-java-3.0.9.jar SuSE Linux 9.1
How can I force the mysql server to use TCP/IP instead of sockets?
I seem to recall reading somewhere that when using jdbc and the mysql-connector for java, that it will always try to connect using TCP/IP, even if the host is localhost. However, on SuSE, the mysql server seems preset to use sockets for localhost.
That's true when using clients programs that use the MySQL C client library. To defeat this, just connect to 127.0.0.1 instead of localhost. The connection will be made to the local host's loopback TCP/IP interface.
However, for Java programs using Connector/J, I don't think it supports Unix socket files, so even for localhost the connection will be made using TCP/IP.
Yes, I recall reading somewhere that it is a Java limitation that prevents Connector/J from connecting to MySQL via socket, thus can't do it via JDBC either.
What was unclear was whether using a JDBC URL like "jdbc:mysql://localhost:3306/dbname" should cause a successful TCP/IP connection, or whether the server would only accept "localhost" connections via socket, causing a rejected connection. I was suspecting the latter, since I also came across a note somewhere that seemed to imply that the folks at SUSE, when building the included version of MySQL, compiled it in such a way that connections to localhost were only possible via socket.
In any case, I've managed to get it to work via experimentation, by using Connector/J version 3.0.15. With version 3.0.9 I couldn't connect. With 3.1.4-beta it seemed to connect but threw an SQLException complaining about being unable to convert some value to a timestamp. Unfortunately, I was also experimenting with other settings, so I can't definitively confirm that the version of Connector/J is the only factor.
But perhaps there is a need for the MySQL servers to be able to be configured to use TCP/IP for host="localhost".
But it's the client that initiates the connection. The server merely responds to connection attempts on whatever network interface the client happens to use.
-- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com




