Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

Conecting to PDB via JDBC failed with ORA-12505

2895718Jan 8 2024 — edited Jan 8 2024

Hi there
I am playing around with setting ub CDB/PDB logic for my client
Now I get an error when connecting via JDBC to the PDB. From e.g. sqlDeveloper locally it works.

We are not using listner.ora by now

Entry in tnsnames.ora:

#
ORCDB01E2,ORCDB01E2.<Domain>=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rcsorcdb01e2.<domain>)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcdb01e2)))
UZNACHDB,UZNACHDB.<domain>=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rcsorcdb01e2.<domain>)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=uznachdb)))

lsnrctl status:

[oracle@rcsorcdb01e2 admin]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 08-JAN-2024 11:13:26
Copyright (c) 1991, 2022, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                08-JAN-2024 10:48:23
Uptime                    0 days 0 hr. 25 min. 2 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/rcsorcdb01e2/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rcsorcdb01e2.<domain>)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=rcsorcdb01e2.<domain>)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/orcdb01e2/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
 Instance "+ASM", status READY, has 1 handler(s) for this service...
Service "+ASM_DATA" has 1 instance(s).
 Instance "+ASM", status READY, has 1 handler(s) for this service...
Service "0c8dde113f3f5cdce063a40ff40aadad" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...
Service "0d059036ea1b44e7e063a40ff40a2098" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...
Service "0e6bcb0de1023765e063a40ff40a8c7c" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...
Service "orcdb01e2" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...
Service "orcdb01e2XDB" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...
Service "uznachdb" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...

lsnrctl services:

[oracle@rcsorcdb01e2 admin]$ lsnrctl services
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 08-JAN-2024 11:15:57
Copyright (c) 1991, 2022, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
Services Summary...
Service "+ASM" has 1 instance(s).
 Instance "+ASM", status READY, has 1 handler(s) for this service...
   Handler(s):
     "DEDICATED" established:0 refused:0 state:ready
        LOCAL SERVER
Service "+ASM_DATA" has 1 instance(s).
 Instance "+ASM", status READY, has 1 handler(s) for this service...
   Handler(s):
     "DEDICATED" established:0 refused:0 state:ready
        LOCAL SERVER
Service "0c8dde113f3f5cdce063a40ff40aadad" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...
   Handler(s):
     "DEDICATED" established:1 refused:0 state:ready
        LOCAL SERVER
Service "0d059036ea1b44e7e063a40ff40a2098" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...
   Handler(s):
     "DEDICATED" established:1 refused:0 state:ready
        LOCAL SERVER
Service "0e6bcb0de1023765e063a40ff40a8c7c" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...
   Handler(s):
     "DEDICATED" established:1 refused:0 state:ready
        LOCAL SERVER
Service "orcdb01e2" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...
   Handler(s):
     "DEDICATED" established:1 refused:0 state:ready
        LOCAL SERVER
Service "orcdb01e2XDB" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...
   Handler(s):
     "D000" established:0 refused:0 current:0 max:1022 state:ready
        DISPATCHER <machine: rcsorcdb01e2.<domain>, pid: 15518>
        (ADDRESS=(PROTOCOL=tcp)(HOST=rcsorcdb01e2.<domain>)(PORT=39553))
Service "uznachdb" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...
   Handler(s):
     "DEDICATED" established:1 refused:0 state:ready
        LOCAL SERVER
Service "uzwildb" has 1 instance(s).
 Instance "orcdb01e2", status READY, has 1 handler(s) for this service...
   Handler(s):
     "DEDICATED" established:1 refused:0 state:ready
        LOCAL SERVER
The command completed successfully

Error Message from script which uses jdbc-connection:

used jdbc-connection: jdbc:oracle:thin:@rcsorcdb01e2.<domain>:1521:uznachdb'

Unexpected error running Liquibase: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
SEVERE 1/8/24 10:33 AM: liquibase: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
       at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:127)
       at liquibase.integration.commandline.Main.doMigration(Main.java:958)
       at liquibase.integration.commandline.Main.run(Main.java:188)
       at liquibase.integration.commandline.Main.main(Main.java:103)
Caused by: liquibase.exception.DatabaseException: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
       at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:247)
       at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:151)
       at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:85)
       ... 3 more

Connection from my local PC via sqlDeveleoper works fine with service name : uznachdb

We are using liquibase (a quiet old version) from different server which has no oracle client installed.
All runs connecting a single database or tthe CDB works - only CDB will return user:passsword error - which is clearly and understandable

Thanks for any hint

Uwe

This post has been answered by 2895718 on Jan 8 2024
Jump to Answer
Comments
Post Details
Added on Jan 8 2024
1 comment
32 views