0

I am trying to use the Ruby on Rails Rake command to migrate to an Oracle database. My database.yml file contains the following:

development:
    adapter: oracle
    database: album_development
    sid: orc1          
    username: system
    password: root

On my PC I have set ORACLE_SID=orcl.

When I run Rake,migrate, I get the following error:

rake aborted!
The driver encountered an error: 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

Can you tell me if I need to modify my listener.ora file to get this to work? My listener.ora file is as follows:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = Lenovo-PC)(PORT = 1521))
    )
  )

DEFAULT_SERVICE_LISTENER = (XE)

The output of the lsnrctl Status command is as follows:

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows: Version 11.2.0.2.0 - Production
Start Date                21-APR-2016 11:14:15
Uptime                    0 days 0 hr. 7 min. 43 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE
Listener Parameter File   C:\oraclexe\app\oracle\product\11.2.0\server\network\admin\listener.ora
Listener Log File         C:\oraclexe\app\oracle\diag\tnslsnr\Lenovo-PC\listener\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Lenovo-PC)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Lenovo-PC)(PORT=8080))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
Service "xe" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
The command completed successfully

Can anyone help / make a suggestion?

4

2 回答 2

0

凯文,

谢谢你的帮助。我将我的更改database.yml为:

development:

  adapter: oracle
  database: xe
  username: system
  password: root

这使我能够连接到数据库。我现在有另一个问题,但我想我可以解决这个问题。亲切的问候,肖恩

于 2016-04-21T14:13:29.213 回答
0

首先,您可以使用TNSPING命令检查数据库是否可以访问

例如:TNSPING xe

你可能使用了 one 而不是 L sid: orc1 应该是 sid: orcl 吗?

于 2016-04-21T11:38:52.017 回答