JDBC and IPv6?

S

spacerook

Has anyone ever made a JDBC connection using an IPv6 URL? I am
setting my URL like so (the address here is fake):

jdbc:mysql://[1111:2222:3333:4444:5555:6666:7777:8888]/mysql

This results in the following error:

Cannot get connection for URL jdbc:mysql://
[1111:2222:3333:4444:5555:6666:7777:8888]/mysql : Illegal connection
port value ':5555:6666:7777:8888]'

I am trying to connect to a MySQL database and am using the MySQL
drivers. The Java program is on a Windows machine, which has IPv6
enabled and can successfully make a IPv6 ping (using ping6) to the
MySQL server. I'm starting Java with -
Djava.net.preferIPv6Addresses=true, which seems to have had no effect.
 
G

Greg R. Broderick

(e-mail address removed) wrote in @n59g2000hsh.googlegroups.com:
Has anyone ever made a JDBC connection using an IPv6 URL? I am
setting my URL like so (the address here is fake):

jdbc:mysql://[1111:2222:3333:4444:5555:6666:7777:8888]/mysql

This results in the following error:

Cannot get connection for URL jdbc:mysql://
[1111:2222:3333:4444:5555:6666:7777:8888]/mysql : Illegal connection
port value ':5555:6666:7777:8888]'

I am trying to connect to a MySQL database and am using the MySQL
drivers. The Java program is on a Windows machine, which has IPv6
enabled and can successfully make a IPv6 ping (using ping6) to the
MySQL server. I'm starting Java with -
Djava.net.preferIPv6Addresses=true, which seems to have had no effect.

What happens when you use a fully-qualified domain name that resolves to the
IPv6 IP address via DNS?

I'd also recommend removing the square brackets surrounding the IPv6 address
in the URL.

Cheers!

--
---------------------------------------------------------------------
Greg R. Broderick (e-mail address removed)

A. Top posters.
Q. What is the most annoying thing on Usenet?
---------------------------------------------------------------------
 
A

a24900

Has anyone ever made a JDBC connection using an IPv6 URL? I am
setting my URL like so (the address here is fake):

jdbc:mysql://[1111:2222:3333:4444:5555:6666:7777:8888]/mysql

My understanding is that mysql's jdbc driver can't handle the numeric
IPv6 address (postgress has a patched driver which can). mysql should
work with a domain name, resolved to an IPv6 address. You don't have
to put the IPv6 address into a DNS server to get it resolved. Putting
the mapping into the local "hosts" file (on systems with a resolver
which uses the file, too) should do.
 
S

spacerook

(e-mail address removed) wrote in @n59g2000hsh.googlegroups.com:


Has anyone ever made a JDBC connection using an IPv6 URL? I am
setting my URL like so (the address here is fake):
jdbc:mysql://[1111:2222:3333:4444:5555:6666:7777:8888]/mysql

This results in the following error:
Cannot get connection for URL jdbc:mysql://
[1111:2222:3333:4444:5555:6666:7777:8888]/mysql : Illegal connection
port value ':5555:6666:7777:8888]'
I am trying to connect to a MySQL database and am using the MySQL
drivers. The Java program is on a Windows machine, which has IPv6
enabled and can successfully make a IPv6 ping (using ping6) to the
MySQL server. I'm starting Java with -
Djava.net.preferIPv6Addresses=true, which seems to have had no effect.

What happens when you use a fully-qualified domain name that resolves to the
IPv6 IP address via DNS?

I'd also recommend removing the square brackets surrounding the IPv6 address
in the URL.

Cheers!

This seems to be morphing into more of a MySQL problem now...

I added an IPv6 address/hostname to my Windows host file. I can use
ping6 on the hostname and it works. Good. But I am now getting a
"Connection Refused" exception when trying to connect to the MySQL
server on the Linux machine.

I tried some experiments on the MySQL Linux box. This command works:

mysql -h 127.0.0.1

But this command gives an error:

mysql -h ::1
"Unknown MySQL Server host '::1'"

I think if I can get that second statement to work (i.e. get the MySQL
server to recognize IPv6 addresses), my problem will be solved.
 
C

CsuElites

jdbc:mysql://[1111:2222:3333:4444:5555:6666:7777:8888]/mysql



Today ,for the first time ,i konw the format of IPV6 address.Thanks!
 
Joined
Jan 11, 2011
Messages
2
Reaction score
0
NOTE: THIS IS NOT A FIX, MYSQL CAN HANDLE THIS IN NEXT RELEASE IF THEY WANT. CHECK LICENCING BEFORE MODIFYING THE SRC CODE.

I think the Mysql JDBC connector does not support the IPv6 Type of addresses.

tried some reverse engineering and experimenting with the mysql JDBC connector source code, I found that it could support IPv6 after all.

mysql-connector-java-5.1.14-bin.jar,class at com.mysql.jdbc/NonRegisteringDriver.java

If you see the code inside function parseHostPortPair(),code is responsible for parsing the host port.since our IPv6 contains multiple colon ":",it fails

protected static String[] parseHostPortPair(String hostPortPair) throws SQLException {
...
if (portIndex != -1)
{
if (portIndex + 1 < hostPortPair.length())
{
String portAsString = hostPortPair.substring(portIndex + 1);
hostname = hostPortPair.substring(0, portIndex);
splitValues[0] = "hostname";
splitValues[1] = portAsString;
}
else
{ throw SQLError.createSQLException(); } } ...

Experiment

Hard code your IPv6 address here splitValues[0] = "fe80::5ed6:baff:fe14:a23e"; and splitValues[1] = null;

ActualFix:To be figured out. How to parse the IPv6 address contianing colons ":"

And see It works :D
 
Joined
Jan 11, 2011
Messages
2
Reaction score
0
Thanks to Mark.
We could make connection to Ipv6 address in a different way with no code changes anywhere.

Read URL : bugs.mysql.com/bug.php?id=8836

in the end ,a comment by Mark Mathew.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top