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

迁移至AWS云的.NET MVC与WebAPI应用连接Oracle RDS时遭遇ORA-12560错误的解决方法

Fixing ORA-12560 Error When Connecting to Oracle RDS from .NET MVC/WebAPI

Hey there, since you can connect to your Oracle RDS instance just fine with SQL Developer, we know the network and RDS core setup are working. The problem is almost certainly tied to how your .NET application is using the Oracle driver or formatting the connection string. Let’s walk through the most common fixes:

1. Check SID vs. Service Name (Most Likely Culprit)

AWS Oracle RDS instances default to using a Service Name instead of a SID (though SID might work in some cases, Service Name is the reliable choice). You can grab the correct Service Name from your working SQL Developer connection:

  • Open SQL Developer, edit your RDS connection, and look at the "Service name" field (it usually looks like db-rds.uryrt6fhe.rds.amazonaws.com)
  • Update your connection string’s CONNECT_DATA section: replace (SID=db-rds) with (SERVICE_NAME=<your-service-name>)

Also, don’t forget to add your username and password to the connection string—your original config was missing these! Here’s the corrected example:

<add key="OracleDatabaseConnectionString" value="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db-rds.uryrt6fhe.rds.amazonaws.com)(PORT=1526))(CONNECT_DATA=(SERVICE_NAME=db-rds.uryrt6fhe.rds.amazonaws.com)));User Id=your_db_user;Password=your_db_pass;" />

2. Use ODP.NET’s Simplified EZConnect Format

If you’re using Oracle’s official ODP.NET driver, skip the complex TNS descriptor entirely and use the simpler EZConnect format. It avoids TNS parsing issues and is cleaner for cloud environments:

<add key="OracleDatabaseConnectionString" value="User Id=your_db_user;Password=your_db_pass;Data Source=db-rds.uryrt6fhe.rds.amazonaws.com:1526/your-service-name;" />

3. Verify Your Oracle Driver Version

Make sure your project is using the ODP.NET Managed Driver (Oracle.ManagedDataAccess.dll) instead of the older unmanaged driver. The managed driver doesn’t require a local tnsnames.ora file (which is easy to mess up in cloud setups) and has better cloud compatibility.

  • If you’re stuck with the unmanaged driver, you’ll need to configure a tnsnames.ora file on your app server with the RDS instance details, then reference the TNS alias in your connection string.

4. Fix Connection String Quoting/Syntax

Your original connection string uses single quotes for the value attribute—while .NET config files allow this, it can sometimes cause parsing conflicts with nested parentheses. Switch to double quotes for the value, and double-check all parentheses are properly paired:

<add key="OracleDatabaseConnectionString" value="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db-rds.uryrt6fhe.rds.amazonaws.com)(PORT=1526))(CONNECT_DATA=(SERVICE_NAME=db-rds.uryrt6fhe.rds.amazonaws.com)));User Id=your_db_user;Password=your_db_pass;" />

5. Confirm App Server Network Access

Even though SQL Developer can connect, double-check that your .NET app’s host (like an EC2 instance or Elastic Beanstalk environment) has outbound access to the RDS instance’s 1526 port via security groups. Test connectivity from the app server with:

telnet db-rds.uryrt6fhe.rds.amazonaws.com 1526
# or if telnet isn't installed
nc -zv db-rds.uryrt6fhe.rds.amazonaws.com 1526

6. Check RDS Instance Status & Parameters

Quickly hop into the AWS Console to confirm:

  • Your RDS instance is in "Available" status
  • The parameter group’s local_listener and remote_listener settings are correctly configured (RDS usually handles this automatically, but it’s worth a quick check if all else fails)

The #1 fix here is almost always mixing up SID and Service Name—once you swap that and add your credentials, you should be good to go.

内容的提问来源于stack exchange,提问作者chesney C.

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 19:42:38