Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
all
-
None
-
Mac OS 10.12 Sierra, Netbeans 8.1/8.2
Description
There is a problem to establish connection to Mariadb using java connector. DriverManager.getConnection returns an exception java.sql.SQLNonTransientConnectionException: Could not connect to 'db server ip':3306: unexpected end of stream, read 0 bytes from 4. This error occurs only with Mac os Sierra.
I have no firewall or anti virus software launched.
I found found that importing mysql-connector to the project solves the problem, even if I load a mariadb driver (Class.forName("org.mariadb.jdbc.Driver").newInstance()
Edit:
After investigation, problem rely on use of ManagementFactory.getRuntimeMXBean().getName() to get process PID. Java execute a DNS query to get hostname. If DNS isn't well configured on server, DNS request may take more time than server permit, and server will close socket. New implementation rely on JNA if present to avoid this problem