On 12/28/05, nikhil kurup
<nikhilgk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have been trying to connect to an Oracle database on a windows
> machine. I succesfully ran a test program using ODBC to connect to
> Oracle, but I am out of luck on doing this with rails.
> I am unable to install the OCI Adapter on Windows and am trying to
> figure it out. Meanwhile, if anyone could provide me with some pointers
> or references, I would be grateful. I am finding it a bit difficult in
> locating the right information.
>
If you install the regular Oracle client (I use the 9i client,
personally), and then this library:
http://www.jiubao.org/ruby-oci8/
..you should be able to access anything defined in your TNSNAMES.ORA file.
Try this to make sure it works, changing the username, password, and
SID to match one of your Oracle systems.
require ''oci8''
conn = OCI8.new(''user_name'',
''secret_passw0rd'', ''SID_name_from_tnsnames'')
if conn.exec("select * from dual").fetch[0] == "X"
puts "Whee!"
else
puts "Database connection failed sanity check."
end
On systems that don''t have the proper environment variables set, you
may also need to do:
ENV["TNS_ADMIN"]=''directory_with_tnsnames_file''
before trying to
connect to something.
If you use the Windows installer, you shouldn''t have a problem.
BEWARE: Most of the Oracle installers don''t select the "Windows
Interfaces" (ODBC) by default. You almost certainly need to choose a
''custom'' install if you want to make use of those as well.
Note that the method I''ve sketched out above using the
''native'' Oracle
interface, not ODBC.