Java Doc for SharedSocket.java in  » Database-JDBC-Connection-Pool » jTDS » net » sourceforge » jtds » jdbc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » jTDS » net.sourceforge.jtds.jdbc 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   net.sourceforge.jtds.jdbc.SharedSocket

All known Subclasses:   net.sourceforge.jtds.jdbc.SharedLocalNamedPipe,  net.sourceforge.jtds.jdbc.SharedNamedPipe,
SharedSocket
class SharedSocket (Code)
This class mananges the physical connection to the SQL Server and serialises its use amongst a number of virtual sockets. This allows one physical connection to service a number of concurrent statements.

Constraints and assumptions:

  1. Callers will not attempt to read from the server without issuing a request first.
  2. The end of a server reply can be identified as byte 2 of the header is non zero.

Comments:
  1. This code will discard unread server data if a new request is issued. Currently the higher levels of the driver attempt to do this but may be we can just rely on this code instead.
  2. A cancel can be issued by a caller only if the server is currently sending data for the caller otherwise the cancel is ignored.
  3. Cancel packets on their own are returned as extra records appended to the previous packet so that the TdsCore module can process them.
This version of the class will start to cache results to disk once a predetermined maximum buffer memory threshold has been passed. Small result sets that will fit within a specified limit (default 8 packets) will continue to be held in memory (even if the memory threshold has been passed) in the interests of efficiency.
author:
   Mike Hutchinson.
version:
   $Id: SharedSocket.java,v 1.39 2007/07/08 21:38:13 bheineman Exp $


Field Summary
final protected  intserverType
    

Constructor Summary
protected  SharedSocket(File bufferDir, int tdsVersion, int serverType)
    
 SharedSocket(ConnectionJDBC2 connection)
     Construct a SharedSocket object specifying host name and port.

Method Summary
 booleancancel(int streamId)
     Send a TDS cancel packet to the server.
 voidclose()
     Close the socket and release all resources.
 voidcloseStream(int streamId)
     Deallocate a stream linked to this socket.
 voiddisableEncryption()
     Disable TLS encryption and switch back to raw TCP/IP socket.
 voidenableEncryption(String ssl)
     Enable TLS encryption by creating a TLS socket over the existing TCP/IP network socket.
 voidforceClose()
     Force close the socket causing any pending reads/writes to fail.
 StringgetCharset()
     Retrieve the character set name used to translate byte arrays to or from Strings.
 CharsetInfogetCharsetInfo()
     Retrieve the character set descriptor used to translate byte arrays to or from Strings.
protected  StringgetHost()
     Get the server host name.
protected  DataInputStreamgetIn()
     Getter for SharedSocket.in field.
static  intgetMemoryBudget()
     Get the global buffer memory limit for all instancs of this driver.
static  intgetMinMemPkts()
     Get the minimum number of memory cached packets.
 byte[]getNetPacket(int streamId, byte buffer)
     Get a network packet.
protected  DataOutputStreamgetOut()
     Getter for SharedSocket.out field.
static  intgetPktLen(byte buf)
     Convert two bytes (in network byte order) in a byte array into a Java short integer.
protected  intgetPort()
     Get the server port number.
 RequestStreamgetRequestStream(int bufferSize, int maxPrecision)
     Obtain an instance of a server request stream for this socket.
 ResponseStreamgetResponseStream(RequestStream requestStream, int bufferSize)
     Obtain an instance of a server response stream for this socket. NB.
 intgetTdsVersion()
     Retrieve the TDS version that is active on the connection supported by this socket.
 booleanisConnected()
     Get the connected status of this socket.
 byte[]sendNetPacket(int streamId, byte buffer)
     Send a network packet.
 voidsetCharsetInfo(CharsetInfo charsetInfo)
     Set the character set descriptor to be used to translate byte arrays to or from Strings.
protected  voidsetIn(DataInputStream in)
     Setter for SharedSocket.in field.
static  voidsetMemoryBudget(int memoryBudget)
     Set the global buffer memory limit for all instances of this driver.
static  voidsetMinMemPkts(int minMemPkts)
     Set the minimum number of packets to cache in memory before writing to disk.
protected  voidsetOut(DataOutputStream out)
     Setter for SharedSocket.out field.
protected  voidsetTdsVersion(int tdsVersion)
     Set the TDS version field.
protected  voidsetTimeout(int timeout)
     Set the socket timeout.

Field Detail
serverType
final protected int serverType(Code)
The servertype one of Driver.SQLSERVER or Driver.SYBASE




Constructor Detail
SharedSocket
protected SharedSocket(File bufferDir, int tdsVersion, int serverType)(Code)



SharedSocket
SharedSocket(ConnectionJDBC2 connection) throws IOException, UnknownHostException(Code)
Construct a SharedSocket object specifying host name and port.
Parameters:
  connection - the connection object
throws:
  IOException - if socket open fails




Method Detail
cancel
boolean cancel(int streamId)(Code)
Send a TDS cancel packet to the server.
Parameters:
  streamId - the RequestStream id boolean true if a cancel is actuallyissued by this method call.



close
void close() throws IOException(Code)
Close the socket and release all resources.
throws:
  IOException - if the socket close fails



closeStream
void closeStream(int streamId)(Code)
Deallocate a stream linked to this socket.
Parameters:
  streamId - the ResponseStream id



disableEncryption
void disableEncryption() throws IOException(Code)
Disable TLS encryption and switch back to raw TCP/IP socket.
throws:
  IOException - if an I/O error occurs



enableEncryption
void enableEncryption(String ssl) throws IOException(Code)
Enable TLS encryption by creating a TLS socket over the existing TCP/IP network socket.
Parameters:
  ssl - the SSL URL property value
throws:
  IOException - if an I/O error occurs



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

Used by the login timer to abort a login attempt.




getCharset
String getCharset()(Code)
Retrieve the character set name used to translate byte arrays to or from Strings. the character set name as a String



getCharsetInfo
CharsetInfo getCharsetInfo()(Code)
Retrieve the character set descriptor used to translate byte arrays to or from Strings.



getHost
protected String getHost()(Code)
Get the server host name. the host name as a String



getIn
protected DataInputStream getIn()(Code)
Getter for SharedSocket.in field. InputStream used for communication



getMemoryBudget
static int getMemoryBudget()(Code)
Get the global buffer memory limit for all instancs of this driver. the memory limit as an int



getMinMemPkts
static int getMinMemPkts()(Code)
Get the minimum number of memory cached packets. minimum memory packets as an int



getNetPacket
byte[] getNetPacket(int streamId, byte buffer) throws IOException(Code)
Get a network packet. This may be read from the network directly or from previously cached buffers.
Parameters:
  streamId - the originating ResponseStream object
Parameters:
  buffer - the data buffer to receive the object (may be replaced) the data in a byte[] buffer
throws:
  IOException - if an I/O error occurs



getOut
protected DataOutputStream getOut()(Code)
Getter for SharedSocket.out field. OutputStream used for communication



getPktLen
static int getPktLen(byte buf)(Code)
Convert two bytes (in network byte order) in a byte array into a Java short integer.
Parameters:
  buf - array of data the 16 bit unsigned value as an int



getPort
protected int getPort()(Code)
Get the server port number. the host port as an int



getRequestStream
RequestStream getRequestStream(int bufferSize, int maxPrecision)(Code)
Obtain an instance of a server request stream for this socket.
Parameters:
  bufferSize - the initial buffer size to be used by theRequestStream
Parameters:
  maxPrecision - the maximum precision for numeric/decimal types the server request stream as a RequestStream



getResponseStream
ResponseStream getResponseStream(RequestStream requestStream, int bufferSize)(Code)
Obtain an instance of a server response stream for this socket. NB. getRequestStream() must be used first to obtain the RequestStream needed as a parameter for this method.
Parameters:
  requestStream - an existing server request stream object obtainedfrom this SharedSocket
Parameters:
  bufferSize - the initial buffer size to be used by theRequestStream the server response stream as a ResponseStream



getTdsVersion
int getTdsVersion()(Code)
Retrieve the TDS version that is active on the connection supported by this socket. the TDS version as an int



isConnected
boolean isConnected()(Code)
Get the connected status of this socket. true if the underlying socket is connected



sendNetPacket
byte[] sendNetPacket(int streamId, byte buffer) throws IOException(Code)
Send a network packet. If output for another virtual socket is in progress this packet will be sent later.
Parameters:
  streamId - the originating RequestStream object
Parameters:
  buffer - the data to send the same buffer received if emptied or another buffer w/ thesame size if the incoming buffer is cached (to avoid copying)
throws:
  IOException - if an I/O error occurs



setCharsetInfo
void setCharsetInfo(CharsetInfo charsetInfo)(Code)
Set the character set descriptor to be used to translate byte arrays to or from Strings.
Parameters:
  charsetInfo - the character set descriptor



setIn
protected void setIn(DataInputStream in)(Code)
Setter for SharedSocket.in field.
Parameters:
  in - the InputStream to be used for communication



setMemoryBudget
static void setMemoryBudget(int memoryBudget)(Code)
Set the global buffer memory limit for all instances of this driver.
Parameters:
  memoryBudget - the global memory budget



setMinMemPkts
static void setMinMemPkts(int minMemPkts)(Code)
Set the minimum number of packets to cache in memory before writing to disk.
Parameters:
  minMemPkts - the minimum number of packets to cache



setOut
protected void setOut(DataOutputStream out)(Code)
Setter for SharedSocket.out field.
Parameters:
  out - the OutputStream to be used for communication



setTdsVersion
protected void setTdsVersion(int tdsVersion)(Code)
Set the TDS version field.
Parameters:
  tdsVersion - the TDS version as an int



setTimeout
protected void setTimeout(int timeout) throws SocketException(Code)
Set the socket timeout.
Parameters:
  timeout - the timeout value in milliseconds



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.