@Override public Socket connect(String host, int portNumber, Properties props) throws SocketException, IOException { // Adjust the path to your MySQL socket by setting the // "junixsocket.file" property // If no socket path is given, use the default: /tmp/mysql.sock final File socketFile = new File(props.getProperty("junixsocket.file", "/tmp/mysql.sock")); socket = AFUNIXSocket.connectTo(new AFUNIXSocketAddress(socketFile)); return socket; } }
@Override public Socket createSocket(String host, int port) throws IOException, UnknownHostException { if (!isHostnameSupported(host)) { throw new UnknownHostException(); } if (port < 0) { throw new IllegalArgumentException("Illegal port"); } AFUNIXSocketAddress socketAddress = addressFromHost(host, port); String socketFile = socketAddress.getSocketFile(); if (socketFile == null || socketFile.isEmpty()) { throw new UnknownHostException("Illegal socketFile"); } File file = new File(socketFile); if (!file.exists()) { throw new UnknownHostException("Socketfile does not exist"); } return AFUNIXSocket.connectTo(socketAddress); }
@Override public Socket createSocket(String host, int port) throws IOException { final RMIClientSocketFactory cf = defaultClientFactory; if (cf != null && port < AFUNIXRMIPorts.AF_PORT_BASE) { return cf.createSocket(host, port); } final AFUNIXSocketAddress addr = new AFUNIXSocketAddress(getFile(port), port); return AFUNIXSocket.connectTo(addr); }
@SuppressWarnings({"unchecked", "exports"}) @Override public <T extends Closeable> T connect(String hostname, int portNumber, PropertySet props, int loginTimeout) throws IOException { // Adjust the path to your MySQL socket by setting the // "junixsocket.file" property // If no socket path is given, use the default: /tmp/mysql.sock RuntimeProperty<String> prop = props.getStringProperty("junixsocket.file"); String sock; if (prop != null && !prop.isExplicitlySet()) { sock = prop.getStringValue(); } else { sock = "/tmp/mysql.sock"; } final File socketFile = new File(sock); this.rawSocket = AFUNIXSocket.connectTo(new AFUNIXSocketAddress(socketFile)); this.sslSocket = rawSocket; return (T) rawSocket; }