KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > jdbcserver > TCPJDBCServerConnection


1 /**
2  * com.mckoi.database.jdbcserver.TCPJDBCServerConnection 22 Jul 2000
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * Version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License Version 2 for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * Version 2 along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  * Change Log:
21  *
22  *
23  */

24
25 package com.mckoi.database.jdbcserver;
26
27 import com.mckoi.database.jdbc.DatabaseInterface;
28 import com.mckoi.debug.DebugLogger;
29
30 import java.net.Socket JavaDoc;
31 import java.io.*;
32
33 /**
34  * A ServerConnection that processes JDBC queries from a client from a
35  * TCP Socket.
36  *
37  * @author Tobias Downer
38  */

39
40 final class TCPJDBCServerConnection extends StreamJDBCServerConnection {
41
42   /**
43    * The socket connection with the client.
44    */

45   private Socket JavaDoc connection;
46
47   /**
48    * Is set to true when the connection to the client is closed.
49    */

50   private boolean is_closed = false;
51
52   /**
53    * Constructs the ServerConnection object.
54    */

55   TCPJDBCServerConnection(DatabaseInterface db_interface,
56                      Socket JavaDoc socket, DebugLogger logger) throws IOException {
57     super(db_interface, socket.getInputStream(),
58           socket.getOutputStream(), logger);
59     this.connection = socket;
60   }
61
62   /**
63    * Completely closes the connection to the client.
64    */

65   public void close() throws IOException {
66     try {
67       // Dispose the processor
68
dispose();
69     }
70     catch (Throwable JavaDoc e) { e.printStackTrace(); }
71     // Close the socket
72
connection.close();
73     is_closed = true;
74   }
75
76   /**
77    * Returns true if the connection to the client has been closed.
78    */

79   public boolean isClosed() throws IOException {
80     return is_closed;
81   }
82
83 }
84
Popular Tags