Documentation Home
MySQL Connector/J 5.1 Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 489.5Kb
PDF (A4) - 491.4Kb
HTML Download (TGZ) - 118.7Kb
HTML Download (Zip) - 136.6Kb


5.4 Named Pipe Connections

Connector/J also supports access to MySQL using named pipes on Windows platforms with the NamedPipeSocketFactory as a plugin-sockets factory. If you do not use a namedPipePath property, the default of '\\.\pipe\MySQL' is used. If you use the NamedPipeSocketFactory, the host name and port number values in the JDBC URL are ignored. To enable this feature, set the socketFactory property:

socketFactory=com.mysql.jdbc.NamedPipeSocketFactory

Set this property, as well as the path of the named pipe, with the following connection URL:

jdbc:mysql:///test?socketFactory=com.mysql.jdbc.NamedPipeSocketFactory&namedPipePath=\\.\pipe\MySQL57

To create your own socket factories, follow the sample code in com.mysql.jdbc.NamedPipeSocketFactory or com.mysql.jdbc.StandardSocketFactory.

An alternate approach is to use the following two properties in connection URLs for establishing named pipe connections on Windows platforms:

  • (protocol=pipe) for named pipes (default value for the property is tcp).

  • (path=path_to_pipe) for path of named pipes. Default value for the path is \\.\pipe\MySQL.

The address-equals form of host specification (see Single host for details) greatly simplifies the URL for a named pipe connection on Windows. For example, to use the default named pipe of \\.\pipe\MySQL, just specify:

jdbc:mysql://address=(protocol=pipe)/test

To use the custom named pipe of \\.\pipe\MySQL57 :

jdbc:mysql://address=(protocol=pipe)(path=\\.\pipe\MySQL80)/test

With (protocol=pipe), the NamedPipeSocketFactory is automatically selected.

Named pipes only work when connecting to a MySQL server on the same physical machine where the JDBC driver is running. In simple performance tests, named pipe access is between 30%-50% faster than the standard TCP/IP access. However, this varies per system, and named pipes are slower than TCP/IP in many Windows configurations.


User Comments
Sign Up Login You must be logged in to post a comment.