Skip Headers
Oracle® Database Express Edition 2 Day Developer's Guide
11g Release 2 (11.2)

Part Number E18147-07
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

2 Connecting to Oracle Database Express Edition

You can connect to Oracle Database Express Edition (Oracle Database XE) only through a client program, such as SQL*Plus or SQL Developer.

This chapter contains the following sections:

Connecting to Oracle Database XE from SQL*Plus

SQL*Plus is a client program with which you can access Oracle Database XE. This section shows how to start SQL*Plus and connect to Oracle Database XE.

Note:

For steps 3 and 4 of the following procedure, you need a user name and password.

To connect to Oracle Database XE from SQL*Plus:

  1. If you are on a Windows system, display a Windows command prompt.

  2. At the command prompt, type sqlplus and press the key Enter.

    SQL*Plus starts and prompts you for your user name.

  3. Type your user name and press the key Enter.

    SQL*Plus prompts you for your password.

  4. Type your password and press the key Enter.

    Note:

    For security, your password is not visible on your screen.

    The system connects you to an Oracle Database XE instance.

    You are in the SQL*Plus environment. At the SQL> prompt, you can enter and run SQL*Plus commands, SQL statements, PL/SQL statements, and operating system commands.

    To exit SQL*Plus, type exit and press the key Enter.

    Note:

    Exiting SQL*Plus ends the SQL*Plus session, but does not shut down the Oracle Database XE instance.

    Example 2-1 starts SQL*Plus, connects to Oracle Database XE, runs a SQL SELECT statement, and exits SQL*Plus. User input is bold.

Example 2-1 Connecting to Oracle Database from SQL*Plus

> sqlplus
SQL*Plus: Release 11.2.0.2.0 Production on Thu Feb 17 09:48:30 2011
 
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
 
Enter user-name: your_user_name
Enter password: your_password
 
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Beta
 
SQL> select count(*) from employees;
 
  COUNT(*)
----------
       107
 
SQL> exit
 
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - Beta
> 

See Also:

Connecting to Oracle Database XE from SQL Developer

SQL Developer is a client program with which you can access Oracle Database XE. With Oracle Database XE 11g Release 2 (11.2), you must use SQL Developer version 3.0. This section assumes that SQL Developer is installed on your system, and shows how to start it and connect to Oracle Database XE. If SQL Developer is not installed on your system, see Oracle Database SQL Developer User's Guide for installation instructions.

Note:

For the following procedure:
  • The first time you start SQL Developer on your system, you must provide the full path to java.exe in step 1.

  • For step 4, you need a user name and password.

  • For step 6, you need a host name and port.

To connect to Oracle Database XE from SQL Developer:

  1. Start SQL Developer.

    For instructions, see Oracle Database SQL Developer User's Guide.

    If this is the first time you have started SQL Developer on your system, you are prompted to enter the full path to java.exe (for example, C:\jdk1.5.0\bin\java.exe). Either type the full path after the prompt or browse to it, and then press the key Enter.

    The Oracle SQL Developer window opens.

  2. In the navigation frame of the window, click Connections.

    The Connections pane appears.

  3. In the Connections pane, click the icon New Connection.

    The New/Select Database Connection window opens.

  4. In the New/Select Database Connection window, type the appropriate values in the fields Connection Name, Username, and Password.

    For security, the password characters that you type appear as asterisks.

    Near the Password field is the check box Save Password. By default, it is deselected. Oracle recommends accepting the default.

  5. In the New/Select Database Connection window, click the tab Oracle.

    The Oracle pane appears.

  6. In the Oracle pane:

    • For Connection Type, accept the default (Basic).

    • For Role, accept the default.

    • In the fields Hostname and Port, either accept the defaults or type the appropriate values.

    • Select the option SID.

    • In the SID field, type accept the default (xe).

  7. In the New/Select Database Connection window, click the button Test.

    The connection is tested. If the connection succeeds, the Status indicator changes from blank to Success.

    Description of success.gif follows
    Description of the illustration success.gif

  8. If the test succeeded, click the button Connect.

    The New/Select Database Connection window closes. The Connections pane shows the connection whose name you entered in the Connection Name field in step 4.

You are in the SQL Developer environment.

To exit SQL Developer, select Exit from the File menu.

Note:

Exiting SQL Developer ends the SQL Developer session, but does not shut down the Oracle Database XE instance. The next time you start SQL Developer, the connection you created using the preceding procedure still exists. SQL Developer prompts you for the password that you supplied in step 4 (unless you selected the check box Save Password).

See Also:

Connecting to Oracle Database XE as User HR

This section shows how to unlock the HR account and connect to Oracle Database XE as the user HR, who owns the HR sample schema that the examples and tutorials in this document use.

To do the tutorials and examples in this document, and create the sample application, you must connect to Oracle Database XE as the user HR from SQL Developer. The HR sample schema is the development environment for the sample application.

Topics:

Unlocking the HR Account

By default, when the HR schema is installed, the HR account is locked and its password is expired. You can connect to Oracle Database as the user HR only if the HR account is unlocked.

Note:

For the following procedure, you need the name and password of a user who has the ALTER USER system privilege (for example, SYSTEM).

To unlock the HR account and reset its password:

  1. Using SQL*Plus, connect to Oracle Database XE as a user with the ALTER USER system privilege.

  2. At the SQL> prompt, unlock the HR account and reset its password:

    Caution:

    Choose a secure password. For guidelines for securing passwords, see Oracle Database Security Guide.
    ALTER USER HR ACCOUNT UNLOCK IDENTIFIED BY password;
    

    The system responds:

    User altered
    

    The HR account is unlocked and its password is password.

Now you can connect to Oracle Database XE as user HR with the password password.

See Also:

Connecting to Oracle Database XE as User HR from SQL*Plus

This section shows how to connect to Oracle Database XE as the user HR from SQL*Plus, if the HR account is unlocked.

To connect to Oracle Database XE as user HR from SQL*Plus:

Note:

For this task, you need the password for the HR account.
  1. If you are connected to Oracle Database XE, close your current connection.

  2. Follow the directions in "Connecting to Oracle Database XE from SQL*Plus", entering the user name HR at step 3 and the password for the HR account at step 4.

    You are now connected to Oracle Database XE as the user HR.

See Also:

SQL*Plus User's Guide and Reference for an example of using SQL*Plus to create an HR connection

Connecting to Oracle Database XE as User HR from SQL Developer

This section shows how to connect to Oracle Database XE as the user HR from SQL Developer, if the HR account is unlocked.

Note:

For the following procedure, you need the password for the HR account.

To connect to Oracle Database XE as user HR from SQL Developer:

Follow the directions in "Connecting to Oracle Database XE from SQL Developer", entering the following values at steps 4:

  • For Connection Name, enter hr_conn.

    (You can enter a different name, but the tutorials in this document assume that you named the connection hr_conn.)

  • For Username, enter HR.

  • For Password, enter the password for the HR account.

You are now connected to Oracle Database XE as the user HR.