Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public abstract class SqlSocket
- Object
- SqlSocket
A connection to a database server, as the wire clients in this package see it.
Each target opens one its own way – the backend over its own sockets, an
application over the port’s – and hands it over through
SqlPlatform.connect(String, int, int). A target that cannot run TLS refuses
the TLS calls: a client asked for TLS fails to connect, it never continues in
the clear.
Constructors
public SqlSocket() |
Methods
Inherited methods
Constructor details
SqlSocket
public SqlSocket()Method details
read
public abstract int read(byte[] buffer, int offset, int length)
throws IOExceptionReads at most
length bytes, blocking until at least one arrives.Returns
the number of bytes read, or -1 at the end of the stream
Throws
write
public abstract void write(byte[] buffer, int offset, int length)
throws IOExceptionWrites all
length bytes.Throws
setReadTimeout
public abstract void setReadTimeout(int millis)
throws IOExceptionHow long a read may block before it fails, in milliseconds; 0 waits forever.
Throws
startTls
public abstract void startTls(String host, String caFile, boolean verifyHost, String alpn)
throws IOExceptionUpgrades the connection to TLS in place, verifying the server’s certificate
against
caFile (or the platform’s trust roots when it is null) and, when
verifyHost is set, its name against host. alpn is the protocol to
offer, or null for none.Throws
startTlsTunnelled
public abstract void startTlsTunnelled(String host, String caFile, boolean verifyHost, int packetType)
throws IOExceptionUpgrades to TLS with the handshake carried inside the protocol’s own
packets of type
packetType (SQL Server’s PRELOGIN); after the handshake
the connection is ordinary TLS.Throws
startTls
public void startTls(String host, String caFile, boolean verifyHost)
throws IOExceptionUpgrades to TLS with no protocol offered; see
startTls(String, String, boolean, String).Throws
close
public abstract void close()Closes the connection; closing twice does nothing.