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 final class Oracle
- Object
- ServerSession
- Oracle
An Oracle Database client speaking TNS and TTC, the protocol of Oracle’s own “thin” drivers. Oracle Database 19c and later.
Oracle db = Oracle.connect("db.internal", 1521, "FREEPDB1", "app", "secret",
"disable", null, 10000, 0);
List rows = db.query("SELECT id, name FROM users WHERE id = :1", new Object[] {7L});Statements
Parameters are written :1, :2 and so on and bound by number: the same
number used twice binds the same value twice. A DML statement that ends in
RETURNING ... INTO :n answers query with one row holding what it
returned. Outside a transaction every statement commits as it completes,
as on the other engines.
Encryption
sslmode require, verify-full and verify-ca connect over TLS
(TCPS), which is a listener port of its own, usually 2484. Without TLS the
password still never crosses the network: the O5LOGON exchange proves it
with keys derived from it. Oracle’s Native Network Encryption is not
implemented, and neither are wallets.
Values
A NUMBER that is a whole number within the range of a long arrives as
Long, any other NUMBER as its exact digits in a String. BINARY_DOUBLE
and BINARY_FLOAT arrive as Double, RAW and BLOB as byte[], text and
CLOB as String, and DATE and TIMESTAMP as yyyy-MM-dd HH:mm:ss[.fff].
Fields
public static final ServerSession.Connector CONNECTOR | Opens Oracle sessions; naming this constant is what puts the engine in an application. |
Methods
Inherited nested types
Inherited methods
Field details
CONNECTOR
public static final ServerSession.Connector CONNECTORServerSession.Connector.Method details
dialect
public Dialect dialect()ownsTransactionControl
public boolean ownsTransactionControl()connect
public static Oracle connect(String host, int port, String service, String user, String password, String sslMode, String caFile, int timeoutMillis, int socketTimeoutMillis)
throws IOExceptionOpens a session to the service service on a listener.
sslMode is what the other engines take, except that a connection
without TLS is a plain listener port and never an attempt that falls
back: require and verify-full demand TLS to a certificate that
verifies for host, and verify-ca a chain to caFile without the name.
Without TLS the password is still never sent, but an active attacker
can pick the verifier and its iteration count and crack the answer
offline, and every row crosses in the clear, so plaintext is only
disable, written deliberately; an absent mode or prefer is refused,
as SQL Server refuses it.
Throws
execute
public int execute(String sql, Object[] params)
throws IOExceptionReturns
Throws
query
public List query(String sql, Object[] params)
throws IOExceptionMap of column name
to value in projection order. A DML statement with RETURNING ... INTO
answers with one row of the values it returned.Throws
begin
public void begin()
throws IOExceptionThrows
beginReadOnly
public void beginReadOnly()
throws IOExceptionThrows
begin
public void begin(boolean readOnly, TransactionIsolation isolation)
throws IOExceptionThrows
commit
public void commit()
throws IOExceptionThrows
rollback
public void rollback()
throws IOExceptionThrows
savepoint
public void savepoint(String verb, String name)
throws IOExceptionThrows
lastInsertId
public long lastInsertId()RETURNING ... INTO.close
public void close()isClosed
public boolean isClosed()