A trivial Oracle OCI-8 question

Hi,

maybe s.b. can help me here – as I have no Oracle db here installed
to help a friend.

  • Does the ruby OCI-8 allow to connect to a remote oracle server?
    My friend got it running locally, but remote connection does not seem
    to work.

this works:
require 'oci8’
conn = OCI8.new($dbuser, $dbpass)

What do I have to change now connect to a different databaseserver?
Let’s try it with localhost first:
conn = OCI8.new($dbuser, $dbpass, “localhost”)
#-> complains about no listener (ORA-12541)

Where is the obvious mistake?

Thanks,
-Armin.

The precise error message is:

OCIError: ORA-12154: TNS:could not resolve service name

which gives you a clue: ‘TNS’ means that the service name has to be listed
in your tnsnames.ora file.

See if you can get as far as using sqlplus to connect to a remote
database, as:
sqlplus user/passwd@dbname

If you can get that working then the ‘dbname’ can also be passed to OCI8 as
the third parameter. Just remember it’s not a hostname, it’s an index into
tnsnames.ora

Can’t give you any more advice about the contents of tnsnames.ora - I try to
get away with knowing as little Oracle as possible!

Regards,

Brian.

···

On Tue, Mar 18, 2003 at 09:58:00PM +0900, Armin Roehrl wrote:

this works:
require ‘oci8’
conn = OCI8.new($dbuser, $dbpass)

What do I have to change now connect to a different databaseserver?
Let’s try it with localhost first:
conn = OCI8.new($dbuser, $dbpass, “localhost”)
#-> complains about no listener (ORA-12541)