I need to establish connection to multitple databases at the same time using the gem 'active_record'
i am using below code to achieve that:
require 'active_record'
conn1 = ActiveRecord::Base.establish_connection(
:adapter => 'oracle_enhanced',
:database => "//db1",
:username => 'user1',
:password => 'pwd1'
)
a = conn1.connection.exec_query("select N_WF_NIE from COMBINED")
puts a
conn2 = ActiveRecord::Base.establish_connection(
:adapter => 'oracle_enhanced',
:database => "db2",
:username => 'user2',
:password => 'pwd2'
)
b = conn2.connection.exec_query("select MSLNN from PICAAMISC")
puts b
Now further in the script when I use the first connection(conn1
) that is nullified and the below query does not return any result.
c = conn1.connection.exec_query("select N_NIE from AGG")
puts c
I want to make sure that both my connections are active at the same time so that I can use any of the connection in the script if required, is there any way to achieve that?