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

Scala连接Oracle数据库报错求助:ORA-01034等错误

Fixing ORA-01034 & ORA-27101 When Connecting Oracle from Scala

Hey there, let's work through this connection error you're facing. That ORA-01034: ORACLE not available paired with ORA-27101: shared memory realm does not exist usually signals issues with the Oracle database instance itself or your connection setup. Here's how to troubleshoot step by step:

1. Verify the Oracle Database Instance is Running

The shared memory error tells us the database process likely isn't active on the server. On your Linux machine:

  • Check for the database instance's monitoring process with:
    ps -ef | grep pmon
    
    You should see a process named ora_pmon_dfdev (matching your dfdev instance). If not, the instance is down.
  • To start it, log into SQL*Plus as a sysdba:
    sqlplus / as sysdba
    
    Then run:
    startup;
    
    If you hit mount issues, try:
    startup mount;
    alter database open;
    

2. Double-Check Your JDBC URL Format

Your current URL uses the service name syntax (@db-dfdev:1521/dfdev), but we need to confirm this is correct:

  • On the database server, run lsnrctl status and look for the "Services Summary" section. Ensure dfdev is listed as a service name.
  • If you intended to use the SID instead, adjust the URL to use a colon separator:
    ods.setURL("jdbc:oracle:thin:@db-dfdev:1521:dfdev")
    

3. Confirm Network Connectivity

Make sure your Scala machine can reach the Oracle server:

  • Test basic connectivity with ping db-dfdev — if this fails, check your DNS settings or add an entry in /etc/hosts for the server.
  • Test the database port with telnet db-dfdev 1521. If the connection is refused:
    • Check the server's firewall rules to ensure port 1521 is open.
    • Verify the Oracle listener is running with lsnrctl status; start it if needed with lsnrctl start.

4. Validate Oracle JDBC Driver Setup

Ensure your Scala project has the correct Oracle JDBC driver dependency, matching your database version. For sbt projects, add this to your build.sbt:

libraryDependencies += "com.oracle.database.jdbc" % "ojdbc8" % "21.13.0.0"

Quick Pre-Code Test

Before debugging your Scala code further, test the connection directly with SQL*Plus from your machine (or the server) to rule out database-side issues:

sqlplus TM_ODS/odstm@db-dfdev:1521/dfdev

If this fails, fix the database/network issues first before revisiting your Scala code.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 04:25:52