代码改变世界

EZConnect to oracle server

2010-08-05 17:25  Tracy.  阅读(839)  评论(0编辑  收藏  举报

Connection Setup Quick Start
======================================================
There are a number of methods to connect Oracle client to a database server. Two of the most common include EZCONNECT and TNSNAMES. EZCONNECT is the easiest to setup. TNSNAMES is much more maintainable in the long term. If you are new to Oracle, we recommend you use EZCONNECT. You only have to choose one or the other to connect.

These quick start instructions assume you have a valid username and password for the database server.

Note: In the setup instructions below, ORACLE_HOME represents the directory where the Oracle client Home was installed on your machine. A typical directory for an OUI Oracle client Home is:
C:\app\<user>\product\11.2.0\client_1
You will need to know where this directory is before proceeding.

EZCONNECT Setup
1. Copy the sqlnet.ora file located in the following directory:
ORACLE_HOME\Network\Admin\Sample\
to this directory:
ORACLE_HOME\Network\Admin\
This file tells the Oracle client by what methods (e.g. EZCONNECT) Oracle client can connect to the Oracle database server.
2. The Oracle client must then specify a valid user name, password, and data source to connect to the database server. To specify a data source, you can use the EZCONNECT format. In the ODP.NET data source attribute, use the following format to define how the client connects to the database server:
[//]host[:port][/service_name]

  • host = the database server machine's host name
  • port = the database server machine's port on which it listens for incoming connection requests
  • service_name = the database's global name
For example, some syntactically valid connection strings follow:
"user id=hr;password=hr;data source=//sales-server:1521/sales.us.acme.com"
"user id=hr;password=hr;data source=//sales-server/sales.us.acme.com"
"user id=hr;password=hr;data source=sales-server/sales.us.acme.com"
If the port number is not specified, 1521 is used by default.