14

I am trying to connect to my Oracle database from SQLPlus, but I'm not able to connect.

I have Oracle client(10g) on my machine. Below are the details through which I am able to connect from my Java application.

connect('dbi:Oracle://IP/wborcle', 'username', 'pwd'));

What will be the hoststring when connecting via SQLPLUS?

3
  • What is the error you're getting? Commented Mar 5, 2014 at 10:39
  • ORA : 12154 TNS : could not resolve the connect identifier specified Commented Mar 5, 2014 at 10:41
  • Are you 100% sure you're using Java? DBI is a Perl library for connecting to Oracle. Commented Mar 5, 2014 at 11:33

5 Answers 5

24

Try

sqlplus username/password@host:port/service

sqlplus system/system@localhost:1521/xe

Copied from https://dba.stackexchange.com/questions/65032/connect-to-sql-plus-from-command-line-using-connection-string

Sign up to request clarification or add additional context in comments.

1 Comment

This method fails to connect to an Oracle database link
8

Oracle offers several different methods for lookup up databases when you're trying to connect to them:

  • tnsnames.ora entries
  • LDAP
  • EZConnect
  • ...

The most common approach is to put the databases you're connecting to into your tnsnames.ora; usually, your client installation contains an example tnsnames.ora file that you can modify.

The easiest approach is probably to use EZConnect. An EZConnect string is built like

<username>/<password>@<hostname>:<port>/SID

so in your case, it (probably) will be something like

sqlplus scott/tiger@localhost:1521/wborcle

Comments

4
 sqlplus user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname.network)(Port=1521))(CONNECT_DATA=(SID=remote_SID)))

Maybe, and this might be dependant on the command line environment you're using, you need to quote the string, something like

sqlplus "user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname.network)(Port=1521))(CONNECT_DATA=(SID=remote_SID)))"

or

 sqlplus 'user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname.network)(Port=1521))(CONNECT_DATA=(SID=remote_SID)))'

2 Comments

Hi Mariano, can you please explain this more. i m not able to understand this.
"Are you 100% sure you're using Java? DBI is a Perl library for connecting to Oracle."
2
sqlplus username/password@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname)(Port=1521))(CONNECT_DATA=(SID=sidname)))

Comments

0

If using the standard client, in order to use ezconnect syntax you may have to set it in your sqlnet.ora file, in the network/admin directory of the client

names.directory_path=(tnsnames,ezconnect)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.