Spring Boot has no OracleTemplate class. To run SQL against Oracle Database you use the general-purpose JdbcTemplate or the newer fluent JdbcClient (Spring Framework 6.1 and later), backed by the Oracle JDBC driver and a Hikari connection pool. Oracle-specific features such as PL/SQL calls, sequences and RETURNING clauses are handled through those same classes, SimpleJdbcCall, or Spring Data JDBC and JPA.
If you saw OracleTemplate in a tutorial, it was either a custom class in someone's project or a mistake. The sections below show the real, supported setup.
Spring's template classes are named after the technology they wrap (JdbcTemplate, RestTemplate, MongoTemplate), not after a vendor. JDBC is a vendor-neutral API, so one JdbcTemplate works with Oracle, PostgreSQL or MySQL. The vendor-specific behaviour comes from the JDBC driver and the SQL dialect you write.
| Need | Use |
|---|---|
| Plain SQL with parameters | JdbcTemplate or JdbcClient |
| Named parameters | NamedParameterJdbcTemplate or JdbcClient |
| Stored procedures and functions | SimpleJdbcCall |
| Inserts that return generated keys | SimpleJdbcInsert or KeyHolder |
| Object mapping, repositories | Spring Data JDBC or Spring Data JPA |
Add the Oracle JDBC driver and the JDBC starter. Use the driver release that matches your database and JDK; ojdbc11 targets Java 11 and later.
Spring Boot manages the ojdbc11 version through its dependency management, so you normally omit it. Then configure the data source:
Boot detects the driver class from the URL, creates a HikariDataSource, and auto-configures a JdbcTemplate and JdbcClient. Read the password from an environment variable or a secret store, not from a committed file. The service name in the URL (FREEPDB1 above) depends on your installation.
JdbcClient is a fluent API with named or positional parameters and direct mapping to records.
Parameters are bound as prepared-statement values, which prevents SQL injection. Never concatenate user input into the SQL string. Column names are matched to record components case-insensitively, so Oracle's upper-case column names map to name and department without extra configuration.
JdbcTemplate offers the same capabilities with positional parameters and a RowMapper.
Both classes acquire and release the connection, close statements and result sets, and translate SQLException into Spring's unchecked DataAccessException hierarchy.
Oracle 12c and later support identity columns. With an older style sequence, select the next value in the same insert:
Use SimpleJdbcCall for stored procedures and functions.
Oracle 12c and later support OFFSET ... FETCH NEXT:
Annotate service methods with @Transactional. Spring Boot configures a DataSourceTransactionManager automatically, so repository calls in the same method share one connection and commit or roll back together.
No. Spring Data has JdbcAggregateTemplate, MongoTemplate and similar classes, but nothing named OracleTemplate. For Oracle you use the standard JDBC or JPA support.
Spring Data JDBC detects the dialect from the driver. With JPA, Hibernate 6 detects the Oracle dialect automatically, so you normally do not set hibernate.dialect.
For new code on Spring Boot 3.2 or later, JdbcClient has a cleaner API. JdbcTemplate remains fully supported and is common in existing code.
Use environment variables, Kubernetes secrets or a secrets manager, and reference them with ${...} placeholders.
There is no OracleTemplate in Spring Boot. Use JdbcClient or JdbcTemplate with the Oracle JDBC driver and Hikari, call PL/SQL with SimpleJdbcCall, and wrap work in @Transactional. For object mapping, move up to Spring Data JDBC or JPA.