I made an app that connects to a database and checks the version the user is running vs the latest version on my site. Everything runs smooth on Windows but on MAC OS, sometimes I get a Comms link failure. So I made a simple connection tester with some code from the internet to troubleshoot this on different MACs to try to narrow down the problem without running the entire app all the time. Luckily, this small code throws the same exception.
The database user has only SELECT privileges, the hostname is correct (tried both the hostname and ip), skip_networking on the database is off, I added the % wildcard to accept connections from all IPs and bind_address is commented out. I can ping the database from terminal on the machine but when I run this tester, it only prints "***** MySQL JDBC Connection To G4THER DBase Tester *****" and throws the exception. I'm fairly new to programming so I am kind of stuck.
here is the tester program to try to reproduce the issue:
here is the Log error I get when I run this in MAC OS Terminal. As I mentionned, all of this works great on Windows, never had any issue.
Well, first: it's not wise to post login credentials public - better you cover up at least the ip/hostname next time.
About the issue: You got an UnknownHostException - so the Mac can't resolve the hostname given - wich doesn't fit the code you posted wich uses an ip.
Well, currently an issue is that the code you posted doesn't match up the stacktrace: Initially you posted code wich used an IP address, but the stacktrace shows a hostname (I wrote the first reply on my phone as I was outside - but if I remember it pretty much shows up what I get when I ask my DNS) - so the DNS record itself seem to be ok - so, this looks like the Mac fails to do a correct DNS lookup.
I don't know Mac, but as it's a descendant of Unix (BSD) it still should have some of the basic POSIX tools available: "dig" - wich is a DNS tool. Open a terminal and type "dig <hostname> A" and see if it can correctly resolve the hostname to the IP. If so try a reverse lookup: "dig -x <IP>" wich should do a reverse lookup and get the hostname back (at least that's what I get - so the PTR seems also correctly set). If both succeeds it seems the Mac can resolve DNS correctly - then it could be an issue with the used VM - type "java -version" it should print out version and vendor of the VM.
You can also try something like this:
to see if Java can resolve the hostname to its IP (as this uses an internal class (couldn't get an example working without) this might only work on an oracle VM).
I sometimes get the same issue. On the Mac with MySQL I can get that error you mentioned or a "Connection lost". However, these issues also happen interactively with DB clients like Navicat so I don't think it's a Java or JDBC issue, but I haven't been able to figure this one out either.
Thank you guys for your help, I'm starting to think the host of my website and database might be the issue, since I can't reproduce the error running everything locally. One of the problems I am facing is that I cannot have Super privileges on the DB since I've done the website/DB on a shared hosting website (Complete beginner here and self-taught), and I can't change parameters like bind_address etc. I guess the best practice would be to have a VPS or at Cloud VPS. Perhaps the connection isn't established because of the bandwidth allocated to other sites or apps/noisy neighboors type of situation?
I think the next logical step would be to move the whole thing to a cloud VPS because I don't think my desktop app would be scalable with this setup, more users would most likely clog the drain further so to speak.
Might've bitten more than I can chew with front-end/back-end developpement of my desktop app and website by myself lol.