From: Brian Candler Date: 2007-06-01T04:26:56+09:00 Subject: Re: Help with Ruby < - > Oracle Connectivity On Fri, Jun 01, 2007 at 03:45:58AM +0900, Peter Bailey wrote: > OK, Brian. Thanks for your help. Well, here's the dinky script I'm > trying to use. This script was borrowed, in fact, from the oci8 site. > > require 'oci8' > require 'dbi' > > begin > # connect to the Oracle server > dbh = DBI.connect("DBI:OCI8:ORCL:graphicsdb- > prod.bna.com/grpprod.bna.com", "user", "passw") > > # get server version string and display it > row = dbh.select_one("SELECT VERSION()") > puts "Server version: " + row[0] > rescue DBI::DatabaseError => e > puts "An error occurred" > puts "Error code: #{e.err}" > puts "Error message: #{e.errstr}" > ensure > # disconnect from server > dbh.disconnect if dbh > end > > And, I get this: > An error occurred > Error code: 12154 > Error message: ORA-12154: TNS:could not resolve the connect identifier > specified > > Program exited with code 0 > > And, here's what I've tried with SQLPlus. It's not doing the same thing > as above, but it's interrogating the same database. > > First, I simply connected to the database using the SQLPlus initial GUI. Can you connect using the sqlplus command line? I didn't even know that sqlplus came in a GUI variant. (Are you sure it's SQLPlus, and not something like Toad?) Your later post says that you connect to "grpprod". In that case, try the pure oci8 script I posted before, using "grpprod" as the database name. And try your DBI script with DBI.connect("DBI:OCI8:grpprod","user","passw") Can you show your entire /etc/tnsnames.ora ? Brian.