当前位置: 代码迷 >> Oracle管理 >> 联接oracle数据库,返回-1034,搞了两天没搞定!
  详细解决方案

联接oracle数据库,返回-1034,搞了两天没搞定!

热度:480   发布时间:2016-04-24 05:09:54.0
连接oracle数据库,返回-1034,搞了两天没搞定!!
linux发行版:centos5.5 x86_64
oracle版本:10g
问题:为什么zxm用户下无法连接数据库,而oracle用户下可以连接数据库?(zxm用户群组和oracle用户群组相同)

一个连接数据库的小程序:
[code=C/C++][/code]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sqlca.h>

EXEC SQL BEGIN DECLARE SECTION;
char username[10];
char password[10];
EXEC SQL END DECLARE SECTION;

int main()
{
  strncpy(username,"bswdb",6);
  strncpy(password,"bswdb",6);
  EXEC SQL CONNECT :username IDENTIFIED BY :password;
  if(0==sqlca.sqlcode){
  printf("success!!\n");
  printf("username:%s\npasswoad:%s\n",username,password);
  }  
  else{ 
  printf("返回错误:%d\n",sqlca.sqlcode);
  printf("username:%s\npasswoad:%s\n",username,password);
  }  
  return 0;
}
####################################################################
在zxm用户下执行结果:
[zxm@localhost test]$ test_oracle 
返回错误:-1034
username:bswdb
passwoad:bswdb:
在oracle用户下执行结果:
[oracle:/home/oracle/test]$./test_oracle 
success!!
username:bswdb
passwoad:bswdb
######################################################################
[color=#FF0000]以下是环境配置:[/color]
用户群组权限zxm用户和oracle用户是相同的:
[oracle:/home/oracle/test]$id
uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba)
[zxm@localhost ~]$ id
uid=505(zxm) gid=501(oinstall) groups=501(oinstall),502(dba)
#######################################################################
监听已打开:
[oracle:/home/oracle]$lsnrctl start
......省略......
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "bswdb" has 1 instance(s).
  Instance "bswdb", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
###############################################################################
数据库已启动:
[oracle:/home/oracle]$sqlplus / as sysdba
SQL> startup
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 2019320 bytes
Variable Size 88080392 bytes
Database Buffers 75497472 bytes
Redo Buffers 2174976 bytes
Database mounted.
Database opened.
##################################################################################
listener.ora的配置:(虚拟机的IP地址是192.168.128.128)
SID_LIST_LISTENER =
  (SID_LIST =
  (SID_DESC =
  (SID_NAME = PLSExtProc)
  (ORACLE_HOME = /u01/oracle/10.2.0.1.0)
  (PROGRAM = extproc)
  )
  (SID_DESC =
  (SID_NAME = bswdb)
  (ORACLE_HOME = /u01/oracle/10.2.0.1.0)
  (global_dbname = bswdb)
  )
  )
LISTENER =
  (DESCRIPTION_LIST =
  (DESCRIPTION =
  (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC3))
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.128)(PORT = 1521))
  )
  )
#####################################################################################
tnsnames.ora的配置:(虚拟机的IP地址是192.168.128.128)
LISTENER_BSWDB =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.128)(PORT = 1521))
BSWDB 
  (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.128)(PORT = 1521))
  (CONNECT_DATA =
  (SERVER = DEDICATED)
  (SERVICE_NAME = bswdb)
  )
  相关解决方案