Source Code Cross Referenced for SharedNamedPipe.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 Referenced  Class Diagram Java Document (Java Doc) 


001:        // jTDS JDBC Driver for Microsoft SQL Server and Sybase
002:        // Copyright (C) 2004 The jTDS Project
003:        //
004:        // This library is free software; you can redistribute it and/or
005:        // modify it under the terms of the GNU Lesser General Public
006:        // License as published by the Free Software Foundation; either
007:        // version 2.1 of the License, or (at your option) any later version.
008:        //
009:        // This library is distributed in the hope that it will be useful,
010:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
011:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:        // Lesser General Public License for more details.
013:        //
014:        // You should have received a copy of the GNU Lesser General Public
015:        // License along with this library; if not, write to the Free Software
016:        // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:        //
018:        package net.sourceforge.jtds.jdbc;
019:
020:        import java.io.BufferedInputStream;
021:        import java.io.DataInputStream;
022:        import java.io.DataOutputStream;
023:        import java.io.IOException;
024:        import java.net.UnknownHostException;
025:
026:        import jcifs.smb.NtlmPasswordAuthentication;
027:        import jcifs.smb.SmbNamedPipe;
028:
029:        /**
030:         * This class implements inter-process communication (IPC) to the
031:         * database server using named pipes.
032:         *
033:         * @todo Extract abstract base class SharedIpc from <code>SharedSocket</code> and this class.
034:         * @todo Implement connection timeouts for named pipes.
035:         *
036:         * @author David D. Kilzer
037:         * @version $Id: SharedNamedPipe.java,v 1.19 2007/07/12 20:34:47 bheineman Exp $
038:         */
039:        public class SharedNamedPipe extends SharedSocket {
040:            /**
041:             * The shared named pipe.
042:             */
043:            private SmbNamedPipe pipe;
044:
045:            /**
046:             * Creates a new instance of <code>SharedNamedPipe</code>.
047:             *
048:             * @param connection
049:             * @throws IOException if the named pipe or its input or output streams do
050:             *                     not open
051:             * @throws UnknownHostException if host cannot be found for the named pipe
052:             */
053:            public SharedNamedPipe(ConnectionJDBC2 connection)
054:                    throws IOException {
055:                super (connection.getBufferDir(), connection.getTdsVersion(),
056:                        connection.getServerType());
057:
058:                NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(
059:                        connection.getDomainName(), connection.getUser(),
060:                        connection.getPassword());
061:
062:                StringBuffer url = new StringBuffer(32);
063:
064:                url.append("smb://");
065:                url.append(connection.getServerName());
066:                url.append("/IPC$");
067:
068:                final String instanceName = connection.getInstanceName();
069:                if (instanceName != null && instanceName.length() != 0) {
070:                    url.append("/MSSQL$");
071:                    url.append(instanceName);
072:                }
073:
074:                String namedPipePath = DefaultProperties
075:                        .getNamedPipePath(connection.getServerType());
076:                url.append(namedPipePath);
077:
078:                setPipe(new SmbNamedPipe(url.toString(),
079:                        SmbNamedPipe.PIPE_TYPE_RDWR, auth));
080:
081:                setOut(new DataOutputStream(getPipe()
082:                        .getNamedPipeOutputStream()));
083:
084:                final int bufferSize = Support.calculateNamedPipeBufferSize(
085:                        connection.getTdsVersion(), connection.getPacketSize());
086:                setIn(new DataInputStream(new BufferedInputStream(getPipe()
087:                        .getNamedPipeInputStream(), bufferSize)));
088:            }
089:
090:            /**
091:             * Get the connected status of this socket.
092:             *
093:             * @return true if the underlying socket is connected
094:             */
095:            boolean isConnected() {
096:                return getPipe() != null;
097:            }
098:
099:            /**
100:             * Close the socket (noop if in shared mode).
101:             */
102:            void close() throws IOException {
103:                super .close();
104:                getOut().close();
105:                getIn().close();
106:                //getPipe().close();
107:            }
108:
109:            /**
110:             * Force close the socket causing any pending reads/writes to fail.
111:             * <p/>
112:             * Used by the login timer to abort a login attempt.
113:             */
114:            void forceClose() {
115:                try {
116:                    getOut().close();
117:                } catch (IOException e) {
118:                    // Ignore
119:                } finally {
120:                    setOut(null);
121:                }
122:
123:                try {
124:                    getIn().close();
125:                } catch (IOException e) {
126:                    // Ignore
127:                } finally {
128:                    setIn(null);
129:                }
130:
131:                setPipe(null);
132:            }
133:
134:            /**
135:             * Getter for {@link SharedNamedPipe#pipe} field.
136:             *
137:             * @return {@link SmbNamedPipe} used for communication
138:             */
139:            private SmbNamedPipe getPipe() {
140:                return pipe;
141:            }
142:
143:            /**
144:             * Setter for {@link SharedNamedPipe#pipe} field.
145:             *
146:             * @param pipe {@link SmbNamedPipe} to be used for communication
147:             */
148:            private void setPipe(SmbNamedPipe pipe) {
149:                this .pipe = pipe;
150:            }
151:
152:            /**
153:             * Set the socket timeout.
154:             * <p/>
155:             * Noop for now; timeouts are not implemented for SMB named pipes.
156:             *
157:             * @param timeout timeout value in milliseconds
158:             */
159:            protected void setTimeout(int timeout) {
160:                // FIXME - implement timeout functionality
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.