PL/SQL Developer使用Oracle轻量客户端连接数据库

时间:2022-11-17 23:01:42

环境介绍:

本人在winxp环境下配置成功,下面是其他人的配置情况。

 

服务器 Windows 7旗舰版 + Oracle 11g R2

客户机 Windows 7专业版 + PL/SQL Developer 7 + instantclient-basic-win32-11.2.0.1.0.zip(去oracle官网下载即可)

 

 

 

配置服务器:

找到目录“…/app/Administrator/product/11.2.0/dbhome_1/NETWORK/ADMIN”下面的listener.oratnsnames.ora两个文件。

修改listener.ora文件:

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = CLRExtProc)

      (ORACLE_HOME = D:/app/Administrator/product/11.2.0/dbhome_1)

      (PROGRAM = extproc)

      (ENVS = "EXTPROC_DLLS=ONLY:D:/app/Administrator/product/11.2.0/dbhome_1/bin/oraclr11.dll")

    )

    (SID_DESC =

      (GLOBAL_DBNAME = [全局数据库名称])

      (ORACLE_HOME = D:/app/Administrator/product/11.2.0/dbhome_1)

      (SID_NAME = [实例名称])

    )

  )

......

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

      (ADDRESS = (PROTOCOL = TCP)(HOST = [服务器的IP地址])(PORT = 1521))

    )

  )

 

修改tnsnames.ora

LOCALORCL =

  (DESCRIPTION =

    (ADDRESS_LIST =

       (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

       (ADDRESS = (PROTOCOL = TCP)(HOST = [服务器的IP地址])(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID = localorcl)

    )

  )

黄色标注的为添加部分,“localorcl”是我自己的数据库名称,按照自己的设置。

 

配置客户机:

Oracle轻量级客户端:

instantclient-basic-win32-11.2.0.1.0.zip解压缩在“D:/ instantclient”中,在“D:/ instantclient”目录下面创建“network”文件夹,在“network”下面创建“admin”文件夹,在“admin”下面创建文件“tnsnames.ora”,“tnsnames.ora”文件内容为:

[实例名] =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = [数据库主机IP地址])(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = [服务名])

    )

  )

PL/SQL Developer

打开PL/SQL DeveloperTools -> Preferences -> Oracle -> Connection

PL/SQL Developer使用Oracle轻量客户端连接数据库

设置Oracle Home为“D:/ instantclient”和OCI Library为“D:/ instantclient/oci.dll

 然后重新启动PL/SQL Developer,在登录界面的“Database”中就会看到刚才设置好的数据库连接,输入有效的用户名和密码就可以登录了。

PL/SQL Developer使用Oracle轻量客户端连接数据库