Internet Features   «Prev  Next»

Lesson 3 Java and Oracle
Objective Explain how Java integrates with Oracle Database 23c/23ai and OCI, and when to use PL/SQL vs. Java.

Java and Oracle in the 23c/23ai Era

Oracle gave DBAs two broad integration models for Java: inside the database (embedded JVM for stored Java) and outside the database (application servers or services that connect over the network). In 23c/23ai and OCI, the external, service-based model is the strategic default, while the embedded JVM remains supported for niche use cases.

Are Java apps with JDBC still used on OCI?

Yes. Java applications that use JDBC are standard on Oracle Cloud Infrastructure (OCI). Typical patterns include:

When to use PL/SQL vs. Java

Combine PL/SQL and Java in stored program units
Historical view (Oracle8i): stored Java/PLSQL in one engine. Modern guidance: keep most business logic in PL/SQL or in external services; use stored Java only when necessary.
JDBC inside database
JDBC remains the primary Java interface to Oracle. Today, use the thin driver, TLS, wallets/mTLS, and UCP/DRCP for scale.
Scalability and shared resources
Modern scalability is achieved via app-tier pooling (UCP/HikariCP), database-tier pooling (DRCP), RAC/Exadata, and OCI private endpoints.

Modern Java ↔ Oracle patterns


Oracle 23ai Database

Reference configuration (Autonomous DB with UCP)


// Java 17+/22, JDBC Thin, UCP, ATP with wallet
import java.sql.*;
import oracle.ucp.jdbc.PoolDataSource;
import oracle.ucp.jdbc.PoolDataSourceFactory;

PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource();
pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
pds.setURL("jdbc:oracle:thin:@adb_high?TNS_ADMIN=/path/to/wallet");
pds.setUser("APPUSER");
pds.setPassword(System.getenv("APP_DB_PASSWORD"));
pds.setMinPoolSize(1);
pds.setMaxPoolSize(50);
pds.setValidateConnectionOnBorrow(true);
// Optional: DRCP
pds.setConnectionProperty("oracle.jdbc.DRCPConnectionClass","appPool");

// Use try-with-resources per request
try (Connection conn = pds.getConnection();
     PreparedStatement ps = conn.prepareStatement(
       "select product_id, name from products where price > ?")) {
  ps.setBigDecimal(1, new java.math.BigDecimal("1000"));
  try (ResultSet rs = ps.executeQuery()) {
    while (rs.next()) {
      // consume rows
    }
  }
}

Design notes and anti-patterns

Where Java shines with 23c/23ai features

Summary

JDBC-based Java applications are alive and well on OCI. Use the thin driver with TLS and wallets, pool connections in the app (UCP/HikariCP), optionally enable DRCP, and push set-based work to SQL/PLSQL. Treat stored Java as a niche tool; prefer external services and ORDS for REST access. This approach yields the best performance, security, and operability in Oracle 23c/23ai.


SEMrush Software 3 SEMrush Banner 3