Class SqlSocket

java.lang.Object
com.codename1.db.sql.SqlSocket

public abstract class SqlSocket extends Object

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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Closes the connection; closing twice does nothing.
    abstract int
    read(byte[] buffer, int offset, int length)
    Reads at most length bytes, blocking until at least one arrives.
    abstract void
    setReadTimeout(int millis)
    How long a read may block before it fails, in milliseconds; 0 waits forever.
    void
    startTls(String host, String caFile, boolean verifyHost)
    Upgrades to TLS with no protocol offered; see startTls(String, String, boolean, String).
    abstract void
    startTls(String host, String caFile, boolean verifyHost, String alpn)
    Upgrades 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.
    abstract void
    startTlsTunnelled(String host, String caFile, boolean verifyHost, int packetType)
    Upgrades 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.
    abstract void
    write(byte[] buffer, int offset, int length)
    Writes all length bytes.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SqlSocket

      public SqlSocket()
  • Method Details

    • read

      public abstract int read(byte[] buffer, int offset, int length) throws IOException

      Reads 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:
      IOException
    • write

      public abstract void write(byte[] buffer, int offset, int length) throws IOException
      Writes all length bytes.
      Throws:
      IOException
    • setReadTimeout

      public abstract void setReadTimeout(int millis) throws IOException
      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 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:
      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 type packetType (SQL Server's PRELOGIN); after the handshake the connection is ordinary TLS.
      Throws:
      IOException
    • startTls

      public void startTls(String host, String caFile, boolean verifyHost) throws IOException
      Upgrades to TLS with no protocol offered; see startTls(String, String, boolean, String).
      Throws:
      IOException
    • close

      public abstract void close()
      Closes the connection; closing twice does nothing.