Class SqlSocket
java.lang.Object
com.codename1.db.sql.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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidclose()Closes the connection; closing twice does nothing.abstract intread(byte[] buffer, int offset, int length) Reads at mostlengthbytes, blocking until at least one arrives.abstract voidsetReadTimeout(int millis) How long a read may block before it fails, in milliseconds; 0 waits forever.voidUpgrades to TLS with no protocol offered; seestartTls(String, String, boolean, String).abstract voidUpgrades the connection to TLS in place, verifying the server's certificate againstcaFile(or the platform's trust roots when it is null) and, whenverifyHostis set, its name againsthost.abstract voidstartTlsTunnelled(String host, String caFile, boolean verifyHost, int packetType) Upgrades to TLS with the handshake carried inside the protocol's own packets of typepacketType(SQL Server's PRELOGIN); after the handshake the connection is ordinary TLS.abstract voidwrite(byte[] buffer, int offset, int length) Writes alllengthbytes.
-
Constructor Details
-
SqlSocket
public SqlSocket()
-
-
Method Details
-
read
Reads at most
lengthbytes, blocking until at least one arrives.Returns
the number of bytes read, or -1 at the end of the stream
- Throws:
IOException
-
write
Writes alllengthbytes.- Throws:
IOException
-
setReadTimeout
How long a read may block before it fails, in milliseconds; 0 waits forever.- Throws:
IOException
-
startTls
public abstract void startTls(String host, String caFile, boolean verifyHost, String alpn) throws IOException Upgrades the connection to TLS in place, verifying the server's certificate againstcaFile(or the platform's trust roots when it is null) and, whenverifyHostis set, its name againsthost.alpnis the protocol to offer, or null for none.- Throws:
IOException
-
startTlsTunnelled
public abstract void startTlsTunnelled(String host, String caFile, boolean verifyHost, int packetType) throws IOException Upgrades to TLS with the handshake carried inside the protocol's own packets of typepacketType(SQL Server's PRELOGIN); after the handshake the connection is ordinary TLS.- Throws:
IOException
-
startTls
Upgrades to TLS with no protocol offered; seestartTls(String, String, boolean, String).- Throws:
IOException
-
close
public abstract void close()Closes the connection; closing twice does nothing.
-