尝试使用ruby

时间:2017-10-02 13:38:19

标签: ruby database oracle

我正在尝试通过ruby连接到oracle db,但是我有一个错误: OCIError:ORA-12514:TNS:el listener no conoce actualmente el servicio solicitado en el descriptordeconexión oci8.c:659:在oci8lib_240.so中 侦听器实际上并不知道连接描述符中所请求的服务。

tames:

SERVICE_PODVCT_ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = podvct.x.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = PODVCT)
      (SERVICE_NAME = PODVCT)
      (SID = PODVCT)
    )
  )

监听器:

LISTENER_PODVCT_ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = podvct.x.com)(PORT = 1521))
    (CONNECT_DATA = 
    (SERVICE_NAME = PODVCT)
    (SID = PODVCT)
    )
  )
  sid_list_LISTENER_PODVCT_ORCL=
   (sid_list=
   (sid_desc=
   (oracle-home=C:\app\user\product\11.2.0\dbhome_1)
   (sid_name=PODVCT)))
ADR_BASE_LISTENER_PODVCT_ORCL = C:\app\user

sqlnet:

AMES.TRACE_DIRECTORY = C:\app\user\product\11.2.0\dbhome_1\NETWORK\trace
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, HOSTNAME)
NAMES.TRACE_FILE = names.trc
NAMESCTL.TRACE_FILE = namesctl.trc
NAMES.PREFERRED_SERVERS =
  (address_list =
    (address = (protocol = tcp)(host = podvct.x.com)(port = 1521))
  )
NAMES.LOG_FILE = names.log
NAMESCTL.TRACE_LEVEL = ADMIN
NAMES.LOG_DIRECTORY = C:\app\user\product\11.2.0\dbhome_1\NETWORK\log
NAMES.DEFAULT_DOMAIN = world
NAMESCTL.TRACE_DIRECTORY = C:\app\user\product\11.2.0\dbhome_1\NETWORK\trace
NAMES.TRACE_LEVEL = ADMIN
ADR_BASE = C:\app\user

我配置了环境变量:

PATH: ...;C:\Ruby24-x64\bin\oci.dll;C:\Oracle_odbc;%ORACLE_HOME%/network/bin;C:\app\PRIVE2\product\11.2.0\dbhome_1\bin;
ORACLE_HOME:C:\app\user\product\11.2.0\dbhome_1
ORACLE_SID:podvct
NLS_LANG: SPANISH_SPAIN.WE8MSWIN1252
TNS_ADMIN: C:\app\USER\product\11.2.0\dbhome_1\NETWORK\ADMIN
  • 在红宝石中,我说:

    要求'dbi' 要求'oci8'

    // dbh = OCI8.new(用户,密码,'podvct.x.com:1521 / PODVCT')

    dbh = DBI.connect(“DBI:OCI8:podvct.x.com:1521 / PODVCT”,用户,密码)

  • 我检查了ruby之后的连接,因为sqlplus和错误是:

    dbh = DBI.connect(“DBI:OCI8:podvct.monsanto.com:1521 / PODVCT”,用户,密码)

OCIError:ORA-12514:TNS:el listener no conoce actualmente el servicio solicitado en el descriptordeconexión oci8.c:659:在oci8lib_240.so中 侦听器实际上并不知道连接描述符中所请求的服务。

1 个答案:

答案 0 :(得分:0)

我尝试所有,响应是这样的红宝石句子:

dbh = DBI.connect(“DBI:OCI8:SERVICE_PODVCT_ORCL”,用户,通过)

SERVICE_PODVCT_ORCL是tnsnames.ora

中服务的名称

谢谢!