Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Database connection via SQLPLUS

Tags:

oracle

sqlplus

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?

like image 493
Aditya Avatar asked Mar 05 '14 10:03

Aditya


3 Answers

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

like image 108
user2128672 Avatar answered Oct 15 '22 04:10

user2128672


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

like image 45
Frank Schmitt Avatar answered Oct 15 '22 05:10

Frank Schmitt


 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)))'
like image 35
Mariano Schmands Avatar answered Oct 15 '22 05:10

Mariano Schmands