Thursday, February 02, 2012

How to configure OracleXEClient to connect to OracleXE?

1. Create a new user Variable called “TNS_ADMIN”
Assume ORACLE_HOME of XE is in C:\oracle\product\oraclexe
Since when you install Oracle 10g Express Edition, a tnsnames.ora file has already been created for you in C:\oracle\product\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\tnsnames.ora
Either set TNS_ADMIN in DOS prompt or in a New User Variable
You can set TNS_ADMIN to your local path of Oracle Express Database
set TNS_ADMIN= C:\oracle\product\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\tnsnames.ora
or you can copy tnsnames.ora from C:\oracle\product\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\tnsnames.ora to C:\oracle\product\XEClient, and set TNS_ADMIN in the User Variable

Click on [Start], Programs, Oracle Client 10g Express Edition, Run SQL Command Line
SQL> connect sys/ora10g_manager@xe as sysdba

Other ways to connect to Oracle Express in DOS prompt

Method 1:
Set TNS_ADMIN in DOS prompt
In DOS prompt,
C:\> set TNS_ADMIN=C:\oracle\product\XEClient
C:\> C:\oracle\product\XEClient\bin\sqlplus.exe /nolog
SQL> connect sys/ora10g_manager@XE as sysdba

Method 2:
No need to set TNS_ADMIN in DOS prompt but enter the full connection string in one line of DOS command
Set NLS_LANG in DOS Prompt
C:\>set NLS_LANG=English
Enter the following DOS command all in ONE line
C:\>sqlplus "sys/ora10g_manager@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE))) as sysdba

Source: https://forums.oracle.com/forums/thread.jspa?threadID=576930