我正在尝试使用Ruby on Rails Rake命令迁移到Oracle数据库。我的database.yml
文件包含以下内容:
development:
adapter: oracle
database: album_development
sid: orc1
username: system
password: root
在我的电脑上,我已经设置了ORACLE_SID=orcl.
当我运行Rake,迁移时,出现以下错误:
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
你能告诉我是否需要修改我的listener.ora
文件才能让它工作吗?我的listener.ora
文件如下:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:oraclexeapporacleproduct11.2.0server)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:oraclexeapporacleproduct11.2.0server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = Lenovo-PC)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
lsnrctl 状态命令的输出如下:
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:oraclexeapporacleproduct11.2.0servernetworkadminlistener.ora
Listener Log File C:oraclexeapporaclediagtnslsnrLenovo-PClisteneralertlog.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\.pipeEXTPROC1ipc)))
(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
任何人都可以帮助/提出建议吗?
首先,您可以使用TNSPING
命令检查数据库是否可访问
例如:TNSPING xe
可能是你用了一个而不是一个L sid:orc1应该是sid:orcl
凯文,
感谢您的帮助。我将database.yml
更改为:
development:
adapter: oracle
database: xe
username: system
password: root
这允许我连接到数据库。我现在有另一个问题,但我认为我可以解决这个问题。亲切的问候,肖恩