# OCI/ODBC on Windows

**URL:** <https://www.ruby-forum.com/t/oci-odbc-on-windows/51267>\
**Category:** Rails\
**Created:** [December 28, 2005, 11:12pm UTC](https://www.ruby-forum.com/t/oci-odbc-on-windows/51267 "2005-12-28T23:12:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikhil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b782af/32.png) [@nikhil](https://www.ruby-forum.com/u/nikhil)\
**Post date:** [December 28, 2005, 11:12pm UTC](https://www.ruby-forum.com/t/oci-odbc-on-windows/51267/1 "2005-12-28T23:12:50Z")

</div>

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.

Thanks,  
Nikhil

---

<div class="post-metadata">

**Author:** ![nikhil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b782af/32.png) [@nikhil](https://www.ruby-forum.com/u/nikhil)\
**Post date:** [December 29, 2005, 5:53pm UTC](https://www.ruby-forum.com/t/oci-odbc-on-windows/51267/2 "2005-12-29T17:53:19Z")

</div>

> I am unable to install the OCI Adapter on Windows and am trying to  
> figure it out.

Install just this file (in the rubyforge project’s page) ignore the  
full archive provided for building.

ruby-oci8-0.1.13-mswin.rb

Works here with 8i and standard client, not yet tested with  
InstantClient.

---

<div class="post-metadata">

**Author:** ![nikhil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b782af/32.png) [@nikhil](https://www.ruby-forum.com/u/nikhil)\
**Post date:** [December 29, 2005, 4:06pm UTC](https://www.ruby-forum.com/t/oci-odbc-on-windows/51267/3 "2005-12-29T16:06:42Z")

</div>

On 12/28/05, nikhil kurup [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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/](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.
