From: Jesse Hu Date: 2008-02-21T12:06:18+09:00 Subject: Re: Confused about OCI8 ------=_Part_519_7653663.1203563186234 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline *TNS-12154 TNS:could not resolve service name.* Can you connect to the Oracle 8 db using sqlplus with this connection string '//10.0.0.22/TEST"? The service_name of the db is "TEST"? 2008/2/21, eddy.pagotto@gmail.com : > > Hi folks, > I'm studying Ruby converting old Java programs. > I'm encoutering many difficults connecting to a Oracle 8.0.6 box (say > responding at 10.0.0.22). > With Java I simply connect using this infos: > > host: 10.0.0.22 > SID: TEST > username: user > password: pwd10 > > and the relative JAR library for Oracle 8. > With Ruby (version 1.8.6/Win32) I installed the OCI8, then I copied > the necessary DLL libraries > from a Oracle/bin directory (such as OCI.DLL) because I don't have the > Oracle client on my machine, > and the Instant client I can download from Oracle's site is the 11g > version which doesn't support Oracle 8. > So, finally I tried some code. > First an example from the Oracle's site: > > ruby -r oci8 -e "OCI8.new('user', 'pwd10', '//10.0.0.22:1521/ > TEST').exec('SELECT * FROM test_table > WHERE rownum = 1') do |r| puts r.join(' | '); end" > > But this error occured: > > env.c:257:in oci8lib.so: Error while trying to retrieve text for error > ORA-06401 (OCIError) > from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:228:in > `initialize' > from -e:1:in `new' > from -e:1 > > > Second, I tried this other example: > > require 'oci8' > > conn = OCI8.new('user', 'pwd10', '//10.0.0.22/TEST') > cursor = conn.exec('SELECT * FROM test_table WHERE rownum = 1') > > while r = cursor.fetch() > puts r.join(',') > end > > cursor.close > conn.logoff > > But this error occured: > > env.c:257:in oci8lib.so: Error while trying to retrieve text for > error ORA-12154 (OCIError) > from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:228:in > `initialize' > from Test.rb:3:in `new' > from Test.rb:3 > > I already look for documentation crawling Google, but it didn't find > anything useful. > Where is my fault? > Thanks in advance for any suggestion to heal my first Ruby-ache. :o) > > Eddy > > > -- Best regards, Jesse ------=_Part_519_7653663.1203563186234--