Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am very new to system and db admin stuffs. Infact, I need to have my skills more improved in those areas. Anyways, I was trying to connect to a remote oracle database and use php oci8 library to talk with that db.

I installed the oracle basic package, sdk and sql plus. For testing the connectivity I ran sqlplus command from /usr/bin which prompts for username and password, If I provide the remote db username and pass it throws an error like this: ORA-12162: TNS:net service name is incorrectly specified.

Also, once I installed oci8. But it seems like oci8 functions are not recognized since the library is not properly installed? How can I check if the library is properly installed?

Update: My OS is Mountain Lion 10.8.4, PHP version is 5.4.10, SQL*Plus: Release 11.2.0.3.0 Production

share|improve this question
    
Is you database and php are on the same server ? –  Nicolas Durand Sep 30 '13 at 8:46
    
No, they're not. –  Nawshad Farruque Sep 30 '13 at 14:58
add comment

1 Answer

The error ORA-12162 is return because the client (sqlplus) doesn't manage to resolve the tns name provided:

 sqlplus user/passwd@ALIAS_TNS

The ALIAS_TNS have to be described in the tnsnames.ora file on the client side. Usually, this file is under ORACLE_HOME/network/admin.

Note that since Oracle 10g another connection syntax exist and does not require the tnsnames.ora. the syntax is:

sqlplus username/password@[//]host[:port][/service_name] 
share|improve this answer
    
running your second command returns a bunch of command suggestions.Something like this: SQL*Plus: Release 11.2.0.3.0 Production on Mon Sep 30 09:35:50 2013 Copyright (c) 1982, 2012, Oracle. All rights reserved. SQL*Plus: Release 11.2.0.3.0 Production Copyright (c) 1982, 2012, Oracle. All rights reserved. Use SQL*Plus to execute SQL, PL/SQL and SQL*Plus statements. ..... Does the mean connection established? How can I run a normal query then? Also, ORACLE_HOME is a directory? I dont find this. How to find that(or set that up if needed?). –  Nawshad Farruque Sep 30 '13 at 15:38
    
ORACLE_HOME is the directory where you have installed your oracle client. And for the 2nd bunch of command, do you have replaced the 'host' by the database server dns name or ip adresse, the 'port' by the listener port on which the oracle server is listening and the 'service_name' by the name of the database ? –  Nicolas Durand Oct 1 '13 at 7:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.