Datapatch Fails in Oracle 12c on Windows – Root Cause and Step-by-Step Fix
4 weeks ago 22
Recently, while applying a patch on an Oracle 12c (12.2.0.1)
database on Windows, I ran into a frustrating issue: datapatch kept failing
with cryptic errors.
D:\oracle\product\12.2.0\dbhome\bin>D:\oracle\product\12.2.0\dbhome\OPatch\datapatch
-verbose
SQL Patching
tool version 12.2.0.1.0 Production on Fri Sep 12 09:11:37 2025
Copyright (c)
2012, 2021, Oracle. All rights
reserved.
Log file for
this invocation:
D:\oracle\product\12.2.0\dbhome\cfgtoollogs\sqlpatch\sqlpatch_5332_2025_09_12_09_11_37\sqlpatch_invocation.log
Connecting to
database...
Connection
using O/S authentication failed.
Enter userid
that can connect as SYSDBA: sys
Enter
password for sys:
Connecting to
database...OK
catconInit
failed, exiting
Please refer
to MOS Note 1609718.1 and/or the invocation log
D:\oracle\product\12.2.0\dbhome\cfgtoollogs\sqlpatch\sqlpatch_5332_2025_09_12_09_11_37\sqlpatch_invocation.log
for
information on how to resolve the above errors.
After verifying the logs pointed to catcon.pl and
sqlpatch_catcon_*.log, the real culprit
turned out to be something deceptively simple — the wrong SQL*Plus version was
being used.
SQL*Plus:
Release 10.1.0.5.0 - Production
ORA-12560:
TNS:protocol adapter error
SP2-0640: Not
connected
This was strange because I was patching a 12.2
database — why would it use a 10.1 client?
Root Cause:-
On Windows, datapatch invokes SQL*Plus internally via catcon.pl.
It will pick up the first sqlplus.exe it finds in the system PATH.To verify this I ran in cmd
D:\oracle\product\12.2.0\dbhome\bin>where
sqlplus
D:\oracle\product\12.2.0\dbhome\bin\sqlplus.exe ← correct (12.2)
D:\oracle\developer\BIN\sqlplus.exe ← wrong (10.1, Oracle Developer 10g)
Since the Developer 10g client was earlier in the PATH, datapatch
tried to use that. And of course, a 10g SQL*Plus cannot talk to a 12c database.Solution:-1. Quick Fix (per session)
Run these commands in your Command Prompt before executing datapatch:
set
ORACLE_HOME=D:\oracle\product\12.2.0\dbhome
set
ORACLE_SID=ORCL
set
PATH=%ORACLE_HOME%\bin;%PATH%
cd
%ORACLE_HOME%\OPatch
datapatch
-verbose
This forces Windows to use the 12.2 SQL*Plus first and the datapatch
was successful.
2. Permanent Fix (system-wide)
Go
to System Properties → Environment Variables
Edit
the PATH variable
Move
D:\oracle\product\12.2.0\dbhome\bin
above:
D:\oracle\developer\BIN
Or remove the old Developer path
completely if you no longer need it.