简体   繁体   中英

How to properly connect ROR with Oracle database with Ruby-OCI8 gem?

I'm trying to use Oracle Database Xe on my ruby on rails app but I'm having a lot of trouble with my database connection I'm currently not sure what the problem is, but according to what I have read I may have a problem with my TNS setup the error message that I'am having is

OCIError: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

The error appears every time I try to run rake db:migrate

on my rails console I try to run OCI8.new and it gives me this error

OCIError: ORA-12545: Connect failed because target host or object does not exist

I'm pretty much stuck and I'm really not sure what to do here.

TNS:

METRO= (description= (address_list= (address = (protocol = TCP)(host = 127.0.0.1)(port = 1521)) ) (connect_data = (service_name=METRO) ) )

Database.yml :

development: adapter: oracle_enhanced database: metro host: 192.168.18.55 username: metro password: imperium

Looks like you are missing the port in database.yml file.

    development:
      adapter: oracle_enhanced
      host: localhost
      port: 1521
      database: xe
      username: user
      password: secret

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM