You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows环境下Oracle XE 11g ORA-12505连接故障求助

Fixing ORA-12505 Error When Connecting Oracle XE 11g with SQL Developer

Hey there, let's work through this ORA-12505 error you're hitting. The fact you can connect as sysdba is a big clue—we can use that access to get things sorted out. Here's a step-by-step breakdown:

1. Verify Your Instance Details

First, fire up your sqlplus sys as sysdba session and run these queries to confirm your database's SID and status:

-- Check instance name and its running status
SELECT instance_name, status FROM v$instance;

-- Check database name (usually matches SID for Oracle XE)
SELECT name FROM v$database;

Note down the instance_name value (it's typically XE for Oracle XE, but let's confirm to be safe).

2. Fix the Listener Configuration (listener.ora)

The ORA-12505 error usually means the listener doesn't recognize your database's SID. Let's update the listener config:

  • Navigate to your Oracle XE's network admin folder. For 11g XE, this is usually C:\oraclexe\app\oracle\product\11.2.0\server\network\admin (adjust the path if your install is in a different location).
  • Open the listener.ora file in a text editor. Look for the SID_LIST_LISTENER section. If it's missing or doesn't include your SID, add this block (replace the ORACLE_HOME path with yours):
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = XE) -- Use the instance_name you found earlier
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
    )
  )

3. Restart the Listener

Now restart the listener to apply the changes. You can do this via command prompt:

lsnrctl stop
lsnrctl start

Alternatively, you can restart the OracleXETNSListener service through Windows Services (search for "Services" in the Start menu to find it).

4. Register the Instance with the Listener

Go back to your sysdba SQL session and run this command to force the database to register itself with the listener:

ALTER SYSTEM REGISTER;

To confirm it worked, run lsnrctl status in command prompt. Look for your SID under the "Services" section—it should show up now.

5. Double-Check SQL Developer Connection Settings

Finally, make sure your SQL Developer connection is configured correctly:

  • Set Connection Type to Basic.
  • Hostname: localhost
  • Port: 1521 (default for Oracle XE)
  • SID: Enter the instance_name you verified earlier (usually XE). Avoid using the Service Name field here unless you specifically set up a service alias.

If you prefer using a TNS connection, update your tnsnames.ora (in the same network admin folder) to include a correct entry for your SID:

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SID_NAME = XE) -- Match your instance_name here
    )
  )

That should get your SQL Developer connection working again. Let me know if any step gives you trouble!

内容的提问来源于stack exchange,提问作者Leo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:39:36