我试图在PHP中使用ODBC访问Oracle数据库。(Apache2、PHP5、ODBC驱动程序和Oracle数据库11.2安装在VirtualBox中的Ubuntu服务器14.04上。)
我已经安装了Oracle数据库,我想我已经配置了tnsnames.ora和ODBC驱动程序:
如果我在使用sqlplus时指定@db
,我会得到一些奇怪的错误(下面的列表)。
以下是tnsnames.ora的配置方式:
# tnsnames.ora Network Configuration File:
MYNAME =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (COMMUNITY = TCP)(PROTOCOL = TCP)(HOST = database)(PORT = 1521))
)
(CONNECT_DATA = (SID = XE))
)
DB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = database)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
开始时,这里有DB
和extproc_connection_data
节,但我还添加了myname
以测试是否应该使用(CONNECT_DATA=(SID=XE))
而不是(SERVICE_NAME=ORCL)
。
sqlplus dbuser@DB
SQL*Plus: Release 11.2.0.2.0 Production on Wed Feb 17 21:22:41 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Enter password:
ERROR:
ORA-12641: Authentication service failed to initialize
sqlplus dbuser@DB
SQL*Plus: Release 11.2.0.2.0 Production on Wed Feb 17 21:22:41 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Enter password:
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
sqlplus dbuser
SQL*Plus: Release 11.2.0.2.0 Production on Wed Feb 17 21:22:41 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Enter password:
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Process ID: 0
Session ID: 0 Serial number: 0
ORA 12514错误:TNS侦听器错误
lsnrctl service
命令的输出,看看注册了哪些服务。service_name
。Alter system register
就可以注册实例。ORA-12514 TNS:侦听器当前不知道现有服务的连接描述符中请求的服务
ORA-12514:TNS:侦听器当前不知道连接描述符中请求的服务
两者都尝试了(local_listener
解决方案)。
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 18-FEB-2016 20:27:56
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 18-FEB-2016 20:21:31
Uptime 0 days 0 hr. 6 min. 25 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service ORCL
Listener Parameter File /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/database/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=database)(PORT=1521)))
Services Summary...
Service "ORCL" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
Service "ORCLXDB" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
SQL*Plus: Release 11.2.0.2.0 Production on Thu Feb 18 20:26:50 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL>
好吧,我是个白痴。
我的/etc/odbc.ini
包含如下内容:
[DB]
Application Attributes = T
Attributes = W
BatchAutocommitMode = IfAllSuccessful
CloseCursor = F
DisableDPM = F
DisableMTS = T
Driver = Oracle 12g ODBC driver
DSN = DB
EXECSchemaOpt =
EXECSyntax = T
Failover = T
FailoverDelay = 10
FailoverRetryCount = 10
FetchBufferSize = 64000
ForceWCHAR = F
Lobs = T
Longs = T
MetadataIdDefault = F
QueryTimeout = T
ResultSets = T
ServerName = localhost/DRORACLE
SQLGetData extensions = F
Translation DLL =
DisableRULEHint = T
UserID = dbuser
StatementCache=F
CacheBufferSize=20
我已经在某个地方复制粘贴了所有这些,并编辑了一些键值对,以便在我的机器上工作。
在过去的几天里,我在其他一些操作系统上使用Oracle数据库。例如,我已经从Oracle站点下载了Oracle DB Developer VM映像,该站点的数据库已经安装并运行良好。
因此,我查看了odbc.ini
中的记录,并决定尝试一些更简单的方法(知道什么在其他机器上运行良好):
[DB2]
Driver = Oracle 12g ODBC driver
DSN = DB
ServerName = database
UserID = dbuser
Password = dbuser
我尝试了ISQL-V DB2
,它成功了!
ServerName = localhost/DRORACLE
ServerName = database
database
==localhost
在我的例子中,只是/etc/hosts
中的另一行。
实际上,当我在第一条记录中更改servername
时,从ISQL-V DB
得到了一条错误消息,但这只是因为该记录缺少password
字段。
我应该补充一点,我在这里使用的是sqlnet.authentication_services=(NONE)
。我不确定确切的原因,但它显示ORA-12641:如果我在那里使用
。对我来说无关紧要,所以如果你要配置它,你可能应该自己弄清楚。(ALL)
,身份验证服务无法初始化
我们在本地运行的应用程序遇到以下错误: ORA-12514:TNS:侦听器当前不知道连接描述符中请求的服务 我使用测试了连接,该连接正确解析,并尝试尝试连接,但失败,错误与上面相同。对于,我使用了以下语法: null 我们不知道对这种环境进行了任何改变。我们还能测试什么吗?
ORA-12514 TNS:侦听器当前不知道连接描述符中请求的服务 我检查了listener.ora和tnsnames.ora,没有找到错误。 Listener.ora 请帮忙。
我在与Toad for Oracle连接时得到了这个错误。
检查下面的配置。如何配置才能使其发挥作用?
从SQL Developer连接到oracle 12c时出现此错误, 我的tnsnames.ora文件内容是: ORACLR_连接_数据=(描述=(地址列表=(地址=(协议=IPC)(键=EXTPROC1521))(连接_数据=(SID=CLRExtProc)(表示=RO))) ORCL1=(描述=(地址\列表=(地址=(协议=TCP)(主机=10.10.1.10)(端口=1521))(连接\数据
我使用的是11G速成版,EclipseJuno,Java6 Oracle已启动并运行,甚至尝试立即关闭和启动,但没有收到SID侦听器错误 错误: 内部异常:java。sql。SQLException:Listener拒绝了连接,出现以下错误:ORA-12505,TNS:Listener当前不知道连接描述符中给出的SID 我istner.ora