且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Oracle Database Link连接错误

更新时间:2022-09-29 08:10:09

案例环境:

NODE1:

操作系统: Linux EL5

Oracle:   Oracle 10gR2

NODE2:

操作系统: Linux EL5

Oracle:   Oracle 11gR2


案例:

    在node1创建到node的database link:

[oracle@rh55 admin]$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jul 8 16:45:01 2014

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options


16:45:02 SYS@ test1asm>create public database link prod

16:45:15   2  connect to scott identified by tiger using 'prod2';

Database link created.

   在连接node2时出现以下错误:

17:32:00 SYS@ test1asm>select * from emp@prod;

select * from emp@prod

                  *

ERROR at line 1:

ORA-01017: invalid username/password; logon denied

ORA-02063: preceding line from PROD

--用户名和密码连接错误

1、确认在node2上的用户名、密码没有问题。

2、tnsnames配置没有问题

PROD2 =

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = prod)

    )

  )

解决方法:

在创建db-link时,将用户密码用“”引起!

17:37:21 SYS@ test1asm>create public database link prod

17:38:12   2  connect to scott identified by "tiger" using 'prod2';

Database link created.


17:38:23 SYS@ test1asm>select * from emp@prod;

   

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
14 rows selected.


 @至此,问题得以解决!










本文转自 客居天涯 51CTO博客,原文链接:http://blog.51cto.com/tiany/1436341,如需转载请自行联系原作者