database.yml settings for SID

205 views
Skip to first unread message

Javix

unread,
May 18, 2016, 11:34:54 AM5/18/16
to Oracle enhanced adapter for ActiveRecord
I can't figuer out how which settings to use among the ones describes at the adapter github repo. No one works, whatever I tried.

I have the following settings in the sqldeveloper for the database to connect:

user name: user
user password : secret
hostname: some.host.org
port: XXXX
SID: sid

Here are the example I tried to use in a rails app  database.yml:

development:
  adapter: oracle_enhanced
  database: some.host.org:1531/sid
  username: user
  password: secret
development:
  adapter: oracle_enhanced
  database: /some.host.org:1531/sid
  username: user
  password: secret
development:
  adapter: oracle_enhanced
  host: some.host.org
  port: XXXX
  database: sid
  username: user
  password: secret
development:
  adapter: oracle_enhanced
  database: //some.host.org:XXXX/SID
  username: user
  password: secret

Another database is defined in sqldeveloper, but it does not have SID but service name defined (SID is empty), the host is the same. 
And I can connect to it without problems.
Even in IntelliJ, I had to define these 2 DBs differently:
jdbc:oracle:thin:@some.host.org:XXXX:sid -> for the DB with SID defined
jdbc:oracle:thin:@//some.host.org:XXXX/service_name - for the DB without SID but with service name defined.
The question is HOW to set the databse with SID properly ? Thank you.
Message has been deleted

Javix

unread,
May 18, 2016, 11:51:42 AM5/18/16
to Oracle enhanced adapter for ActiveRecord
The working settings for the database with service name defined (in a simple ruby script):

ActiveRecord::Base.establish_connection(
  adapter
: 'oracle_enhanced',
  host
: 'some.host.org',
  port
: 'XXXX',
  database
: 'service_name',
  username
: 'user',
  password
: 'secret'
)

Javix

unread,
May 18, 2016, 4:05:21 PM5/18/16
to Oracle enhanced adapter for ActiveRecord


On Wednesday, May 18, 2016 at 5:34:54 PM UTC+2, Javix wrote:
I've just forgotten to precise the OS:

- Windows 7, x64
- Ruby 2.3 

Lori Olson

unread,
May 18, 2016, 5:18:28 PM5/18/16
to oracle-...@googlegroups.com
The method of last resort is usually:

development:
  adapter: oracle_enhanced
  database: "(DESCRIPTION=
    (ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
    (CONNECT_DATA=(SID=your_sid))
  )"
  username: user
  password: secret

Using the entire TNS connection descriptor.  Another alternative, is having your TNS_ADMIN environment variable point to the directory containing your tnsnames.ora, and then you can just specify a connection name from tnanames.ora as your database.

Good luck!

Regards, Lori

-- 
You received this message because you are subscribed to the Google Groups "Oracle enhanced adapter for ActiveRecord" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oracle-enhanc...@googlegroups.com.
To post to this group, send email to oracle-...@googlegroups.com.
Visit this group at https://groups.google.com/group/oracle-enhanced.
For more options, visit https://groups.google.com/d/optout.

Serguei Cambour

unread,
May 19, 2016, 3:12:41 AM5/19/16
to oracle-...@googlegroups.com
Thank you, Lori, your solution worked for me.

Regards

Cynthia Kiser

unread,
May 20, 2016, 3:13:51 PM5/20/16
to oracle-...@googlegroups.com
Well the good news is that error is coming from Oracle - from the TNS listener. But you have the wrong SID. When debugging connections, I always start with the lowest layer and build up. I suggest you sort out connection parameters using sqlplus, then Ruby OCI, then put those parameters into your database.yml and connect with ActiveRecord / Rails.

On Wed, May 18, 2016 at 8:41 AM, Javix <s.ca...@gmail.com> wrote:


On Wednesday, May 18, 2016 at 5:34:54 PM UTC+2, Javix wrote:
When trying just to check it with OCI as follows, it fails:

oci = OCI8.new('user', 'secret', 'some.host.org:XXXX/SID')
puts oci
.inspect


$ ruby oci_connection
.rb
oci8
.c:654:in oci8lib_230.so: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor (OCIError)
       
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby-oci8-2.2.2-x64-mingw32/lib/oci8/oci8.rb:142:in `initialize'
        from oci_connection.rb:3:in `
new'
        from oci_connection.rb:3:in `<main>'

--
You received this message because you are subscribed to the Google Groups "Oracle enhanced adapter for ActiveRecord" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oracle-enhanc...@googlegroups.com.
To post to this group, send email to oracle-...@googlegroups.com.
Visit this group at https://groups.google.com/group/oracle-enhanced.
For more options, visit https://groups.google.com/d/optout.



--
Cynthia Kiser
cynthi...@gmail.com
Reply all
Reply to author
Forward
0 new messages