Top Description Inners Fields Constructors Methods
org.hsqldb.server

pack-priv Class ServerConnection

Additional top-level classes in compilation unit: InResultProcessor, CleanExit.

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.io.BufferedInputStream, .ByteArrayInputStream, .DataInputStream, .EOFException, .IOException, java.net.Socket, .SocketException, java.util.concurrent.atomic.AtomicLong, org.hsqldb.ClientConnection, .ColumnBase, .DatabaseManager, .HsqlException, .Session, .StatementTypes, org.hsqldb.error.Error, .ErrorCode, org.hsqldb.lib.DataOutputStream, org.hsqldb.navigator.RowSetNavigator, org.hsqldb.persist.HsqlDatabaseProperties, org.hsqldb.resources.ResourceBundleHandler, org.hsqldb.result.Result, .ResultConstants, .ResultMetaData, .ResultProperties, org.hsqldb.rowio.RowInputBinary, .RowOutputBinary, .RowOutputInterface, org.hsqldb.types.DateTimeType, .Type

All ServerConnection objects are listed in a Set in server and removed by this class when closed.

When the database or server is shutdown, the signalClose() method is called for all current ServerConnection instances. This will call the private close() method. If the ServerConnection thread itself has caused the shutdown it returns the result of the operation to the client. (fredt@users)

ODBC support added for version 2.0.0 by Blaine Simpson.

ODBC support updated for version 2.5.x. (fredt@users)

Authors
Blaine Simpson (unsaved@users dot sourceforge.net, Fred Toussi (fredt@users dot sourceforge.net)
Since
1.6.2
Version
2.7.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv class
pack-priv class

Field Summary

Modifier and TypeField and Description
pack-priv static final int
private CleanExit
public static long
CLIENT_DATA_POLLING_PERIOD

Don't want this too high, or users may give up before seeing the banner.

private DataInputStream
private DataOutputStream
pack-priv int
pack-priv int
pack-priv static final int
pack-priv boolean
pack-priv final byte[]
private static AtomicLong
private long
pack-priv static final int
pack-priv int
private OdbcPacketOutputStream
pack-priv InResultProcessor
pack-priv RowInputBinary
pack-priv RowOutputInterface
pack-priv Thread
private Server
private volatile Session
private Map<String, StatementPortal>
private Map<String, OdbcPreparedStatement>
private Socket
private int
protected static String
protected static String
pack-priv static final int
private String

Constructor Summary

AccessConstructor and Description
pack-priv
ServerConnection(Socket
the network socket on which Server communication takes place
socket
,
Server
the Server instance to which the object represents a connection
server
)

Creates a new ServerConnection to the specified Server on the specified socket.

Method Summary

Modifier and TypeMethod and Description
private Result
private void
close()

Closes this connection.

pack-priv String

Returns:

the thread name to be used when this object is the Runnable object of a Thread.
getConnectionThreadName
()

Retrieves the thread name to be used when this object is the Runnable object of a Thread.

public int

Returns:

int read as first thing off of stream
handshake
()

The only known case where a connection attempt will get stuck is if client connects with hsqls to a https server; or hsql to a http server.

private void
init()

Initializes this connection.

private void
odbcConnect(int firstInt)

private void
odbcExecDirect(String inStatement)

private static String
readNullTermdUTF(int
Required length
reqLength
,
InputStream istream)

Read String directly from dataInput.

private void
private void
receiveResult(int resultMode)

public void
run()

Implements java.lang.Runnable.run.

Initializes this connection and runs the request handling loop until closed.

private Result
setDatabase(Result resultIn)

pack-priv void
signalClose()

Signals this object to close, including exiting the thread running the request handling loop

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BUFFER_SIZEback to summary
pack-priv static final int BUFFER_SIZE
cleanExitback to summary
private CleanExit cleanExit
CLIENT_DATA_POLLING_PERIODback to summary
public static long CLIENT_DATA_POLLING_PERIOD

Don't want this too high, or users may give up before seeing the banner. Can't be too low or we could close a valid but slow client connection.

dataInputback to summary
private DataInputStream dataInput
dataOutputback to summary
private DataOutputStream dataOutput
dbIDback to summary
pack-priv int dbID
dbIndexback to summary
pack-priv int dbIndex
HSQL_STREAM_PROTOCOLback to summary
pack-priv static final int HSQL_STREAM_PROTOCOL
keepAliveback to summary
pack-priv boolean keepAlive
mainBufferback to summary
pack-priv final byte[] mainBuffer
mCurrentThreadback to summary
private static AtomicLong mCurrentThread
mThreadback to summary
private long mThread
ODBC_STREAM_PROTOCOLback to summary
pack-priv static final int ODBC_STREAM_PROTOCOL
odbcCommModeback to summary
pack-priv int odbcCommMode
outPacketback to summary
private OdbcPacketOutputStream outPacket
processorback to summary
pack-priv InResultProcessor processor
rowInback to summary
pack-priv RowInputBinary rowIn
rowOutback to summary
pack-priv RowOutputInterface rowOut
runnerThreadback to summary
pack-priv Thread runnerThread
serverback to summary
private Server server
sessionback to summary
private volatile Session session
sessionOdbcPortalMapback to summary
private Map<String, StatementPortal> sessionOdbcPortalMap
sessionOdbcPsMapback to summary
private Map<String, OdbcPreparedStatement> sessionOdbcPsMap
socketback to summary
private Socket socket
streamProtocolback to summary
private int streamProtocol
TEXTBANNER_PART1back to summary
protected static String TEXTBANNER_PART1
TEXTBANNER_PART2back to summary
protected static String TEXTBANNER_PART2
UNDEFINED_STREAM_PROTOCOLback to summary
pack-priv static final int UNDEFINED_STREAM_PROTOCOL
userback to summary
private String user

Constructor Detail

ServerConnectionback to summary
pack-priv ServerConnection(Socket socket, Server server)

Creates a new ServerConnection to the specified Server on the specified socket.

Parameters
socket:Socket

the network socket on which Server communication takes place

server:Server

the Server instance to which the object represents a connection

Method Detail

cancelStatementback to summary
private Result cancelStatement(Result resultIn)
closeback to summary
private void close()

Closes this connection.

getConnectionThreadNameback to summary
pack-priv String getConnectionThreadName()

Retrieves the thread name to be used when this object is the Runnable object of a Thread.

Returns:String

the thread name to be used when this object is the Runnable object of a Thread.

handshakeback to summary
public int handshake() throws IOException

The only known case where a connection attempt will get stuck is if client connects with hsqls to a https server; or hsql to a http server. All other client X server combinations are handled gracefully.

If returns (a.o.t. throws), then state variable streamProtocol will be set.

Returns:int

int read as first thing off of stream

initback to summary
private void init()

Initializes this connection.

Will return (not throw) if fail to initialize the connection.

odbcConnectback to summary
private void odbcConnect(int firstInt) throws IOException
odbcExecDirectback to summary
private void odbcExecDirect(String inStatement) throws RecoverableOdbcFailure, IOException
readNullTermdUTFback to summary
private static String readNullTermdUTF(int reqLength, InputStream istream) throws IOException

Read String directly from dataInput.

Parameters
reqLength:int

Required length

receiveOdbcPacketback to summary
private void receiveOdbcPacket(char inC) throws IOException, CleanExit
receiveResultback to summary
private void receiveResult(int resultMode) throws CleanExit, IOException
runback to summary
public void run()

Implements java.lang.Runnable.run.

Initializes this connection and runs the request handling loop until closed.

setDatabaseback to summary
private Result setDatabase(Result resultIn)
signalCloseback to summary
pack-priv void signalClose()

Signals this object to close, including exiting the thread running the request handling loop

org.hsqldb.server back to summary

private Class ServerConnection.ClientFailure

extends Exception
Class Inheritance

Field Summary

Modifier and TypeField and Description
private String

Constructor Summary

AccessConstructor and Description
public
ClientFailure(String ourMessage, String clientMessage)

Method Summary

Modifier and TypeMethod and Description
public String

Field Detail

clientMessageback to summary
private String clientMessage

Constructor Detail

ClientFailureback to summary
public ClientFailure(String ourMessage, String clientMessage)

Method Detail

getClientMessageback to summary
public String getClientMessage()
org.hsqldb.server back to summary

pack-priv Class ServerConnection.HsqlInResultProcessor

extends Object
implements InResultProcessor
Class Inheritance
All Implemented Interfaces
org.hsqldb.server.InResultProcessor

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

HsqlInResultProcessorback to summary
pack-priv HsqlInResultProcessor()

Method Detail

receiveConnectionback to summary
public void receiveConnection(int type) throws CleanExit, IOException

Implements org.hsqldb.server.InResultProcessor.receiveConnection.

receiveResultback to summary
public void receiveResult(int type) throws CleanExit, IOException

Implements org.hsqldb.server.InResultProcessor.receiveResult.

org.hsqldb.server back to summary

pack-priv Class ServerConnection.OdbcInResultProcessor

extends Object
implements InResultProcessor
Class Inheritance
All Implemented Interfaces
org.hsqldb.server.InResultProcessor

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

OdbcInResultProcessorback to summary
pack-priv OdbcInResultProcessor()

Method Detail

receiveConnectionback to summary
public void receiveConnection(int type) throws IOException

Implements org.hsqldb.server.InResultProcessor.receiveConnection.

receiveResultback to summary
public void receiveResult(int type) throws CleanExit, IOException

Implements org.hsqldb.server.InResultProcessor.receiveResult.