Top Description Inners Fields Constructors Methods
org.h2.server

public Class TcpServerThread

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.io.ByteArrayInputStream, .FilterInputStream, .IOException, .InputStream, .PrintWriter, .StringWriter, java.net.Socket, java.sql.SQLException, java.util.ArrayList, .List, .Objects, org.h2.api.ErrorCode, org.h2.command.Command, org.h2.engine.ConnectionInfo, .Constants, .Engine, .GeneratedKeysMode, .Session, .SessionLocal, .SessionRemote, .SysProperties, org.h2.expression.Parameter, .ParameterInterface, .ParameterRemote, org.h2.jdbc.JdbcException, org.h2.jdbc.meta.DatabaseMetaServer, org.h2.message.DbException, org.h2.result.BatchResult, .ResultColumn, .ResultInterface, .ResultWithGeneratedKeys, org.h2.store.LobStorageInterface, org.h2.util.IOUtils, .NetUtils, .NetworkConnectionInfo, .SmallLRUCache, .SmallMap, .TimeZoneProvider, org.h2.value.Transfer, .Value, .ValueLob

One server thread is opened per client connection.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
TcpServerThread.CachedInputStream

An input stream with a position.

Field Summary

Modifier and TypeField and Description
private final SmallMap
private int
private Command
private long
private final SmallLRUCache<Long, TcpServerThread.CachedInputStream>
private final TcpServer
private SessionLocal
private String
private boolean
private Thread
private final int
protected final Transfer

Constructor Summary

AccessConstructor and Description
pack-priv
TcpServerThread(Socket socket, TcpServer server, int id)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
cancelStatement(String
the session id
targetSessionId
,
int
the statement to cancel
statementId
)

Cancel a running statement.

pack-priv void
close()

Close a connection.

private void
private int
getState(int oldModificationId)

pack-priv Thread
private void
private Object
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

private void
sendError(Throwable t, boolean withStatus)

private void
private void
sendRows(ResultInterface result, long count)

private void
private void
pack-priv void
setThread(Thread thread)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private final SmallMap cache
clientVersionback to summary
private int clientVersion
commitback to summary
private Command commit
lastRemoteSettingsIdback to summary
private long lastRemoteSettingsId
lobsback to summary
private final SmallLRUCache<Long, TcpServerThread.CachedInputStream> lobs
serverback to summary
private final TcpServer server
sessionback to summary
private SessionLocal session
sessionIdback to summary
private String sessionId
stopback to summary
private boolean stop
threadback to summary
private Thread thread
threadIdback to summary
private final int threadId
transferback to summary
protected final Transfer transfer

Constructor Detail

TcpServerThreadback to summary
pack-priv TcpServerThread(Socket socket, TcpServer server, int id)

Method Detail

cancelStatementback to summary
pack-priv void cancelStatement(String targetSessionId, int statementId)

Cancel a running statement.

Parameters
targetSessionId:String

the session id

statementId:int

the statement to cancel

closeback to summary
pack-priv void close()

Close a connection.

closeSessionback to summary
private void closeSession()
getStateback to summary
private int getState(int oldModificationId)
getThreadback to summary
pack-priv Thread getThread()
processback to summary
private void process() throws IOException
readGeneratedKeysRequestback to summary
private Object readGeneratedKeysRequest() throws IOException
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
sendErrorback to summary
private void sendError(Throwable t, boolean withStatus)
sendGeneratedKeysback to summary
private void sendGeneratedKeys(ResultInterface generatedKeys) throws IOException
sendRowsback to summary
private void sendRows(ResultInterface result, long count) throws IOException
sendSQLExceptionback to summary
private void sendSQLException(SQLException e) throws IOException
setParametersback to summary
private void setParameters(Command command) throws IOException
setThreadback to summary
pack-priv void setThread(Thread thread)
traceback to summary
private void trace(String s)
org.h2.server back to summary

pack-priv Class TcpServerThread.CachedInputStream

extends FilterInputStream
Class Inheritance

An input stream with a position.

Field Summary

Modifier and TypeField and Description
private static final ByteArrayInputStream
private long
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public long
public int
read(byte[]
the buffer into which the data is read.
buff
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.

public int
read()

Overrides java.io.FilterInputStream.read.

Reads the next byte of data from the input stream.

public long
skip(long
the number of bytes to be skipped.
n
)

Overrides java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream.

Inherited from java.io.FilterInputStream:
availableclosemarkmarkSupportedreadreset

Field Detail

DUMMYback to summary
private static final ByteArrayInputStream DUMMY
posback to summary
private long pos

Constructor Detail

CachedInputStreamback to summary
pack-priv CachedInputStream(InputStream in)

Method Detail

getPosback to summary
public long getPos()
readback to summary
public int read(byte[] buff, int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Parameters
buff:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
skipback to summary
public long skip(long n) throws IOException

Overrides java.io.FilterInputStream.skip.

Doc from java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.

Parameters
n:long

the number of bytes to be skipped.

Returns:long

the actual number of bytes skipped.

Annotations
@Override
Exceptions
IOException:
if in.skip(n) throws an IOException.