Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Cannot connect to Oracle database within a Spring Boot application using docker compose

$
0
0

I've a Spring boot application which I'd like to connect with an Oracle database, containerised using Oracle Database Free Container / Docker images. image.

Additionally, I use docker compose to configure the database deployment and Spring Boot Docker Compose to run the deployment on application startup.

However, My application cannot connect to the database due to the following error:

java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=V0w3NC+xSxaZYliy+XojdA==)    at oracle.jdbc.driver.T4CConnection.handleLogonNetException(T4CConnection.java:892) ~[ojdbc8-21.9.0.0.jar:21.9.0.0.0]    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:697) ~[ojdbc8-21.9.0.0.jar:21.9.0.0.0]

The Oracle container looks good:

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_FREE)))2023-12-18T19:40:23.357410157Z Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))2023-12-18T19:40:23.357437163Z 2023-12-18T19:40:23.357462169Z Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_FREE)))2023-12-18T19:40:23.377109429Z STATUS of the LISTENER2023-12-18T19:40:23.377387489Z ------------------------2023-12-18T19:40:23.377432499Z Alias                     LISTENER2023-12-18T19:40:23.377468507Z Version                   TNSLSNR for Linux: Version 23.0.0.0.0 - Production2023-12-18T19:40:23.377499514Z Start Date                18-DEC-2023 19:40:232023-12-18T19:40:23.377528520Z Uptime                    0 days 0 hr. 0 min. 0 sec2023-12-18T19:40:23.377556526Z Trace Level               off2023-12-18T19:40:23.381577398Z Security                  ON: Local OS Authentication2023-12-18T19:40:23.381807448Z SNMP                      OFF2023-12-18T19:40:23.381845456Z Default Service           FREE2023-12-18T19:40:23.381875462Z Listener Parameter File   /opt/oracle/product/23c/dbhomeFree/network/admin/listener.ora2023-12-18T19:40:23.381903469Z Listener Log File         /opt/oracle/diag/tnslsnr/f8cd793dc1d4/listener/alert/log.xml2023-12-18T19:40:23.381930474Z Listening Endpoints Summary...2023-12-18T19:40:23.383162742Z   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_FREE)))2023-12-18T19:40:23.383223755Z   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))2023-12-18T19:40:23.383255762Z The listener supports no services2023-12-18T19:40:23.385380222Z The command completed successfully2023-12-18T19:40:33.630788572Z ORACLE instance started.

Also, the datasource configuration and docker compose setup are inline with gvenzl/oracle-free:latest image setup instructions

Spring application config:

spring:  liquibase:    enabled: false  datasource:    url: jdbc:oracle:thin:@localhost:1521/FREEPDB1    username: PERSONS_DB    password: Lider0ne

Docker compose setup

services:  oracle:    image: 'gvenzl/oracle-free:latest'    environment:      - 'ORACLE_RANDOM_PASSWORD=true'      - 'APP_USER=PERSONS_DB'      - 'APP_USER_PASSWORD=Lider0ne'    ports:      - 1521:1521

Finally, I get a similar error connecting to the database using IntelliJ Database tool window.

IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=gZO5dOjYRGKjaOL469MGIw==).

enter image description here

NOTE: I run docker on Apple M chip

According to Oracle Database Free documentation, it shouldn't be problem, I followed its instructions to run the container using colima with --arch -x86_64 option. The container started successfully as explained above.

Have you experienced the same issue? If so, how could I fix it


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>