Properties hostSpecificProps = NonRegisteringDriver.expandHostKeyValues(hostnameToConnectTo);
String protocol = hostSpecificProps.getProperty(NonRegisteringDriver.PROTOCOL_PROPERTY_KEY);
if ("unix".equalsIgnoreCase(protocol)) {
SocketFactory factory;
try {
factory = (SocketFactory) Class
.forName(
"org.newsclub.net.mysql.AFUNIXDatabaseSocketFactory")
.newInstance();
} catch (InstantiationException e) {
throw new SocketException(e.getMessage());
} catch (IllegalAccessException e) {
throw new SocketException(e.getMessage());
} catch (ClassNotFoundException e) {
throw new SocketException(e.getMessage());
}
String path = hostSpecificProps
.getProperty(NonRegisteringDriver.PATH_PROPERTY_KEY);
if (path != null) {
hostSpecificProps.setProperty("junixsocket.file", path);
}
return new HangingSocket(factory.connect(hostnameToConnectTo,
portNumber, hostSpecificProps), props, hostname);
}
}