Oracle - 使用 MS Access 的 ODBC 连接错误 (ORA-12154)

发布于 2024-07-08 06:10:17 字数 598 浏览 16 评论 0原文

我正在尝试使用 MS Access 连接到 Oracle 数据库。 我不断收到以下错误消息:

ORA-12154: TSN- 无法解析指定的连接标识符

Oracle 驱动程序 OracleClient10g 可以验证数据库服务器是否存在。

我的 tsnnames.ora 文件中有一个部分如下所示: UBASEP10G = (描述= (地址列表= (地址 = (协议 = TCP)(主机 = bxxx-xxx.yyyy.com)(端口 = 1521)) ) (连接数据= (服务名称=UBASE) ) )

根据我尝试解决此错误的方法,我将其添加到 sqlnet.ora 文件中:

NAMES.DIRECTORY_PATH= (HOSTNAME, ONAMES, TNSNAMES,LDAP,EZCONNECT)

当使用 Windows ODBC 驱动程序配置实用程序时,它会要求以下内容 以下信息 数据源名称:我的源名称 TSN 服务名称:UBASEP10G USERID:MYUSERID

有什么建议吗???

I am trying to use MS access to connect to a Oracle database.
I keep on getting the following error message:

ORA-12154: TSN- could not resolve the connect identifier secified

The Oracle Drivers OracleClient10g can verify that the database server exists.

I have a section in my tsnnames.ora file that looks like this:
UBASEP10G =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = bxxx-xxx.yyyy.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = UBASE)
)
)

per my attempts to get this error resolves I added this to the sqlnet.ora file:

NAMES.DIRECTORY_PATH= (HOSTNAME, ONAMES, TNSNAMES,LDAP,EZCONNECT)

When using the Windows ODBC driver configuration utility it asks for the following
following information
DATA SOURCE NAME : MYSOURCE NAME
TSN SERVICE NAME:UBASEP10G
USERID:MYUSERID

any suggestions ?????

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

嘦怹 2024-07-15 06:10:18

我没有 Access,但使用 Excel 2007,我必须执行以下操作:

  1. 打开 ODBC 管理器(在管理员控制面板中)
  2. 对于用户 DSN 或系统 DSN,单击添加...
  3. 选择“Oracle in OraDb10g_home1”作为driver
  4. 在 Oracle ODBC 驱动程序配置中,我输入:
    • 数据源名称:myOracleDsn
    • 描述:这是我的 Oracle 数据库的 DSN
    • TNS 服务名称:oratns
    • 用户 ID:scott
  5. 单击“测试连接”,然后输入“tiger”作为密码。 显然,我正在连接到我的 scott/tiger 示例 Oracle 数据库。 另外,当我安装 Oracle 时,我选择了 oratns 作为我的 TNS 名称。 上面的其他两个值是任意的——您将在 Excel 的对话框中看到它们。
  6. 如果测试有效,请单击“确定”。
  7. 转到 Excel 并建立与 DSN 的新连接。 该对话框将显示“myOracleDsn”作为选项。 选择它,再次输入“tiger”作为密码,您应该会获得有效的连接。

I don't have Access, but using Excel 2007, I had to do the following:

  1. Open ODBC Administrator (in the Administrator Control Panel)
  2. For either User DSN or System DSN, click Add...
  3. Select "Oracle in OraDb10g_home1" as the driver
  4. In the Oracle ODBC Driver Configuration, I entered:
    • Data Source Name: myOracleDsn
    • Description: This is my DSN for my Oracle Database
    • TNS Service Name: oratns
    • User ID: scott
  5. Click Test Connection, and enter "tiger" for the password. Obviously, I'm connecting to my scott/tiger sample Oracle database. Also, when I installed Oracle, I picked oratns as my TNS name. The other two values above are arbitrary -- you'll see them in dialogs in Excel.
  6. If the test works, click OK.
  7. Go to Excel and make a new connection to a DSN. The dialog will show "myOracleDsn" as an option. Select it, enter "tiger" for the password again, and you should get a working connection.
月寒剑心 2024-07-15 06:10:18

尝试在 TNSNAMES.ora 文件中将 (CONNECT_DATA = (SERVICE_NAME = UBASE) ) 更改为 (CONNECT_DATA = (SID = UBASE) ) 。

ServiceName 和 SID 不一定相同,因此并不总是可以互换。

SERVICENAME 参数引用数据库服务器上的listener.ora 文件中指定的特定GLOBAL_DBNAME。 它是服务器上实例的别名。 一台服务器上可以有多个引用相同 SID 的服务名称。 SID 参数指的是该服务器上的特定实例。

在客户端使用服务名称的优点是,DBA 可以对使用该名称的客户端透明地更改服务名称所引用的实际实例。 我可以将其放在服务器上的listener.ora文件上:

(SID_DESC =
  (GLOBAL_DBNAME = THESERVICE)
  (ORACLE_HOME = d:\oracle\10.2.0_DB)
  (SID_NAME = SID1)

稍后,我可以通过切换listener.ora配置来更改所引用的实际数据库:

(SID_DESC =
  (GLOBAL_DBNAME = THESERVICE)
  (ORACLE_HOME = d:\oracle\10.2.0_DB)
  (SID_NAME = SID2)

并且客户端上没有人更明智。 无需对客户端上的 tnsnames.ora 文件进行任何更改。

Try changing (CONNECT_DATA = (SERVICE_NAME = UBASE) ) to (CONNECT_DATA = (SID = UBASE) ) in your TNSNAMES.ora file.

ServiceName and SID aren't necessarily the same and consequently aren't always interchangeable.

The SERVICENAME parameter refers to a particular GLOBAL_DBNAME specified in the listener.ora file on the database server. It's an alias for an instance on the server. You can have multiple servicenames on a server referring to the same SID. The SID parameter refers to a particular instance on that server.

The advantage of using servicename on the client side is that the DBA can change the actual instance being referenced by a servicename transparently to the clients using that name. I can have this on the server listener.ora file:

(SID_DESC =
  (GLOBAL_DBNAME = THESERVICE)
  (ORACLE_HOME = d:\oracle\10.2.0_DB)
  (SID_NAME = SID1)

Later, I can change the actual database being referenced by switching the listener.ora configuration:

(SID_DESC =
  (GLOBAL_DBNAME = THESERVICE)
  (ORACLE_HOME = d:\oracle\10.2.0_DB)
  (SID_NAME = SID2)

and nobody's the wiser on the client side. No changes were necessary in the tnsnames.ora files on the clients.

葬花如无物 2024-07-15 06:10:18

您可以通过 SQL*Plus 登录到有问题的数据库吗? 从另一台具有工作连接的计算机(或数据库服务器本身)执行此操作也可以。

如果是这样,请运行以下命令:

select value from v$parameter where name='service_names';

在 TNSNAMES.ORA 中,使用其中列出的 SERVICE_NAME 值之一。

在 ODBC 连接中,您只需将 TNS 服务名称设置为上面使用的名称“UBASEP10G”

Can you log in to the database in question via SQL*Plus? Doing this from another machine with a working connection (or the DB server itself) is fine also.

If so, run this:

select value from v$parameter where name='service_names';

In your TNSNAMES.ORA, use one of the values listed there for the SERVICE_NAME.

In you ODBC connection, all you'll need is to set the TNS Service Name to the name you used above, "UBASEP10G"

指尖上得阳光 2024-07-15 06:10:18

让我们回到第一个方面。 打开命令窗口并连接到数据库:

sqlplus myuserid/mypassword@UBASEP10G

连接成功吗?

既然答案是否定的,有没有办法可以成功连接到这个数据库? BQ是正确的,你的问题是UBASE的服务名。 您需要确定服务器上的侦听器认为该数据库的名称是什么。 您有权访问服务器吗? 您可以在服务器上执行命令“lsnrctl status”吗? 这将告诉您向侦听器注册的服务,如下所示:

Services Summary...
Service "UBASE" has 1 instance(s).
  Instance "UBASE", status READY, has 1 handler(s) for this service...

Let's back up to square one. Open a command window and connect to your database:

sqlplus myuserid/mypassword@UBASEP10G

Does this connect successfully?

Since the answer is no, is there a way you CAN connect successfully to this database? BQ is correct, your problem is with the servicename of UBASE. You need to determine what the listener on the server thinks the name of that database is. Do you have access to the server? Can you execute the command "lsnrctl status" on the server? This will tell you the services that are registered with the listener, and look something like this:

Services Summary...
Service "UBASE" has 1 instance(s).
  Instance "UBASE", status READY, has 1 handler(s) for this service...
怪异←思 2024-07-15 06:10:18

尝试 tnsping 并报告您的结果。

坏:

C:\>tnsping notreal.world

TNS Ping Utility for 32-bit Windows: Version 9.2.0.5.0 - Production on 29-OCT-2008 15:56:47

Copyright (c) 1997 Oracle Corporation.  All rights reserved.

Used parameter files:
C:\oracle\ora92\network\admin\sqlnet.ora

TNS-03505: Failed to resolve name

好:

O:\>tnsping real.world

TNS Ping Utility for 32-bit Windows: Version 9.2.0.5.0 - Production on 29-OCT-2008 15:57:42

Copyright (c) 1997 Oracle Corporation.  All rights reserved.

Used parameter files:

C:\oracle\ora92\network\admin\sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = DBSERVER.DOMAIN.COM)(PORT = 1521)) (LOAD_BALANCE = YES) (FAILOVER = YES))
(CONNECT_DATA = (SERVICE_NAME = REAL.WORLD) 
(FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 10) (DELAY = 3))))
OK (40 msec)

Try tnsping and report your results.

Bad:

C:\>tnsping notreal.world

TNS Ping Utility for 32-bit Windows: Version 9.2.0.5.0 - Production on 29-OCT-2008 15:56:47

Copyright (c) 1997 Oracle Corporation.  All rights reserved.

Used parameter files:
C:\oracle\ora92\network\admin\sqlnet.ora

TNS-03505: Failed to resolve name

Good:

O:\>tnsping real.world

TNS Ping Utility for 32-bit Windows: Version 9.2.0.5.0 - Production on 29-OCT-2008 15:57:42

Copyright (c) 1997 Oracle Corporation.  All rights reserved.

Used parameter files:

C:\oracle\ora92\network\admin\sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = DBSERVER.DOMAIN.COM)(PORT = 1521)) (LOAD_BALANCE = YES) (FAILOVER = YES))
(CONNECT_DATA = (SERVICE_NAME = REAL.WORLD) 
(FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 10) (DELAY = 3))))
OK (40 msec)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文