net.sourceforge.jtds.jdbc
Class SharedNamedPipe

java.lang.Object
  |
  +--net.sourceforge.jtds.jdbc.SharedSocket
        |
        +--net.sourceforge.jtds.jdbc.SharedNamedPipe

public class SharedNamedPipe
extends SharedSocket

This class implements inter-process communication (IPC) to the database server using named pipes.

Version:
$Id: SharedNamedPipe.java,v 1.12 2004/08/28 19:10:01 bheineman Exp $
Author:
David D. Kilzer

Inner classes inherited from class net.sourceforge.jtds.jdbc.SharedSocket
SharedSocket.VirtualSocket
 
Field Summary
private  jcifs.smb.SmbNamedPipe pipe
          The shared named pipe.
 
Fields inherited from class net.sourceforge.jtds.jdbc.SharedSocket
cancelMonitor, cancelPending, charsetInfo, doneBuffer, globalMemUsage, hdrBuf, host, in, maxBufSize, memoryBudget, minMemPkts, out, packetCount, peakMemUsage, port, responseOwner, securityViolation, serverType, socket, socketTable, sslSocket, TDS_DONE_LEN, TDS_DONE_TOKEN, TDS_HDR_LEN, tdsVersion
 
Constructor Summary
private SharedNamedPipe()
          Default constructor.
 
Method Summary
private  int calculateBufferSize(int tdsVersion, int packetSize)
          Calculate the buffer size to use when buffering the SmbNamedPipe InputStream.
(package private)  void close()
          Close the socket (noop if in shared mode)
(package private)  void forceClose()
          Force close the socket causing any pending reads/writes to fail.
private  jcifs.smb.SmbNamedPipe getPipe()
          Getter for pipe field.
(package private) static SharedNamedPipe instance(java.lang.String host, int tdsVersion, int serverType, int packetSize, java.lang.String instance, java.lang.String domain, java.lang.String user, java.lang.String password)
          Construct a SharedNamedPipe to the server.
(package private)  boolean isConnected()
          Get the connected status of this socket.
private  void setPipe(jcifs.smb.SmbNamedPipe pipe)
          Setter for pipe field.
protected  void setTimeout(int timeout)
          Set the socket timeout.
 
Methods inherited from class net.sourceforge.jtds.jdbc.SharedSocket
cancel, closeStream, dequeueInput, disableEncryption, enableEncryption, enqueueInput, getCharset, getCharsetInfo, getHost, getIn, getMemoryBudget, getMinMemPkts, getNetPacket, getOut, getPktLen, getPort, getRequestStream, getResponseStream, getServerType, getTdsVersion, lookup, readPacket, sendNetPacket, setCharsetInfo, setIn, setMemoryBudget, setMinMemPkts, setOut, setServerType, setTdsVersion
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

pipe

private jcifs.smb.SmbNamedPipe pipe
The shared named pipe.
Constructor Detail

SharedNamedPipe

private SharedNamedPipe()
Default constructor.
Method Detail

instance

static SharedNamedPipe instance(java.lang.String host,
                                int tdsVersion,
                                int serverType,
                                int packetSize,
                                java.lang.String instance,
                                java.lang.String domain,
                                java.lang.String user,
                                java.lang.String password)
                         throws java.io.IOException,
                                java.net.UnknownHostException
Construct a SharedNamedPipe to the server.
Parameters:
host - The SQL Server host name.
tdsVersion - The TDS protocol version.
serverType - The server type (SQL Server or Sybase).
packetSize - The data packet size (used for buffering the named pipe input stream).
instance - The database instance name.
domain - The domain used for Windows (NTLM) authentication.
user - The username.
password - The password.
Throws:
java.io.IOException - If named pipe or its input or output streams do not open.
java.net.UnknownHostException - If host cannot be found for the named pipe.

isConnected

boolean isConnected()
Get the connected status of this socket.
Overrides:
isConnected in class SharedSocket
Returns:
True if the underlying socket is connected.

close

void close()
     throws java.io.IOException
Close the socket (noop if in shared mode)
Overrides:
close in class SharedSocket
Following copied from class: net.sourceforge.jtds.jdbc.SharedSocket
Throws:
java.io.IOException - if the socket close fails

forceClose

void forceClose()
Force close the socket causing any pending reads/writes to fail.

Used by the login timer to abort a login attempt.

Overrides:
forceClose in class SharedSocket

getPipe

private jcifs.smb.SmbNamedPipe getPipe()
Getter for pipe field.
Returns:
The SmbNamedPipe used for communication.

setPipe

private void setPipe(jcifs.smb.SmbNamedPipe pipe)
Setter for pipe field.
Parameters:
pipe - The SmbNamedPipe to be used for communication.

setTimeout

protected void setTimeout(int timeout)
Set the socket timeout.
Overrides:
setTimeout in class SharedSocket
Parameters:
timeout - the timeout value in milliseconds

calculateBufferSize

private int calculateBufferSize(int tdsVersion,
                                int packetSize)
Calculate the buffer size to use when buffering the SmbNamedPipe InputStream. The buffer size is tied directly to the packet size because each request to the SmbNamedPipe will send a request for a particular size of packet. In other words, if you only request 1 byte, the SmbNamedPipe will send a request out and only ask for 1 byte back. Buffering the expected packet size ensures that all of the data will be returned in the buffer without wasting any space.

assert (packetSize == 0 || (packetSize >= TdsCore.MIN_PKT_SIZE && packetSize <= TdsCore.MAX_PKT_SIZE))

Parameters:
packetSize - The requested packet size for the connection.
Returns:
minimum default packet size if packetSize == 0, else packetSize


Generated on April 15 2005