免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1286 | 回复: 2
打印 上一主题 下一主题

求助 连接oracle数据库出错??? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-02-26 11:28 |只看该作者 |倒序浏览
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <malloc.h>
#include "sqlora.h"
#define  MAX_LOOPS  10
int main()
{
  int status;
  int dbh;
  char *g_cstr = "test/test@testdb";
  status = sqlo_init(0, MAX_LOOPS, 50);
  if (SQLO_SUCCESS != status)
  {
         printf ("sqlo_init failed. Exiting\n");
         exit(1);
   }
  else
         printf("Database initalized successfully!\n");
                                                                              
            
/*Connect  the Database*/
  status = sqlo_connect(&dbh, g_cstr);
  if (SQLO_SUCCESS != status)
    {
      printf ("sqlo_connect failed. Exiting!\n");
      exit(1);
    }
   else
   {
     printf("Database connected successfully!\n");
   }
}
使用的是 libsqlora8,但不知道为什么总是显示无法连接数据库,请各位大虾多多帮忙,我用oracle用户登录的,数据库用户名和密码都是test,数据库名testdb ,不知道这么写对不对?"test/test@testdb";

论坛徽章:
0
2 [报告]
发表于 2006-02-26 23:20 |只看该作者
是tnsnames里的连接串吗?

论坛徽章:
0
3 [报告]
发表于 2006-02-27 12:37 |只看该作者

回复 2楼 caribe 的帖子

不好意思,我不知道什么是tnsnames,您说的是"test/test@testdb"吗?是connect用的参数,我不知道是不是应该这么写,test/test是我数据库的用户名和密码,testdb是数据库名。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP