我遇到和别人的帖子相同的问题,Tuxedo连接Oracle的问题。
=======================================
原贴描述:
===========================================
客户程序如下:我oracle10只有一个数据库是orcl
oracleclient.c
#include <stdio.h>
#include <atmi.h>
#include <string.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
char *sendbuf,*recvbuf;
long sendlen,recvlen;
int ret;
if(argc!=2){
printf("please call the format as : oracleclient %s n",argv[0]);
(void) fprintf(stderr, "Usage: oracleclient stringn");
exit(1);
}
if(tpinit((TPINIT *)NULL)==-1){
(void)fprintf(stderr,"failed to init!n");
exit(1);
}
sendlen=strlen(argv[1]);
if((sendbuf=(char *)tpalloc("STRING",NULL,sendlen+1))==-1){
(void)fprintf(stderr,"failed to allocate memory to sendbuf!n");
tpterm();
exit(1);
}
if((recvbuf=(char *)tpalloc("STRING",NULL,5*sendlen+1))==-1){
(void)fprintf(stderr,"failed to allocate memory for recvbuf!n");
tpterm();
exit(1);
}
strcpy(sendbuf,argv[1]);
ret = tpcall("ORACLES", (char *)sendbuf, 0, (char **)&recvbuf, &recvlen, (long)0);
if(ret==-1){
(void) fprintf(stderr, "Can't send request to service oracleservern");
(void) fprintf(stderr, "Tperrno = %d, %sn, ", tperrno, tpstrerror(tperrno));
tpfree(sendbuf);
tpfree(recvbuf);
tpterm();
exit(1);
}
(void)fprintf(stdout,"the return result is :%s n",recvbuf);
tpfree(sendbuf);
tpfree(recvbuf);
tpterm();
return 0;
}
服务器server程序如下:
oracleserv.pc
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include <userlog.h>
exec sql include sqlca;
tpsvrinit(int argc,char *argv[])
{
if(tpopen()==-1){
printf("error to connect to oracle!n");
}
printf("the oracleserv successfully to connect to db2 in linux!n");
return 0;
}
ORACLES(TPSVCINFO *rqst)
{
exec sql begin declare section;
char db_string[50];
exec sql end declare section;
int i=0;
for(i=0;i<rqst->len-1;i++){
db_string=rqst->data;
}
exec sql delete from system.hmptest where username=:db_string;
if(sqlca.sqlcode!=0){
printf("delete error!n");
tpreturn(TPFAIL,0,NULL,0,0);
}
tpreturn(TPSUCCESS,0,rqst->data,0L,0);
}
tpsvrdone()
{
if(tpclose()==-1){
printf("oracleserv close error!n");
return;
}
printf("oracleserv disconnected!n");
return;
}
编译完全通过:
proc oracleserv.c parse=full include=/home/oracle/oracle/product/10.2.0/db_1/precomp/public include=/home/tuxedo/bea/tuxedo9.1/include
buildserver -o oracleserv -f "oracleserv.c -I/home/oracle/oracle/product/10.2.0/db_1/precomp/public" -r Oracle_XA -s ORACLES
没有错误。。正常运行
buildclient -o oracleclient -f oracleclient.c
但是那个exec sql delete from system.hmptest where username=:db_string;,..为什么不能执行
我的RM文件里用户密码是system/oracle
在sqlplus 里system/oracle能完全操作hmptest数据表。。。
===========================================
[ 本帖最后由 simhare 于 2009-6-29 11:09 编辑 ]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
=========
做过这个的很少吗?怎么没有多少人呢?
哪位高手做过,给各提示吧?谢谢!!!
===============
忘了说我的环境:
CentOS+Oracle11g+Tuxedo10
===============
*GROUPS
GROUP1
LMID=xamh
GRPNO=1
OPENINFO="ORACLE_XA:Oracle_XA+Acc=P/scott/tiger+sqlNet=ORCL+SesTm=100+LogDir=..+MaxCur=5"
CLOSEINFO=""
TMSNAME="TMS_ORA10g"
===================
这一节,我用的是OPENINFO="ORACLE_XA:Oracle_XA+Acc=P/scott/tiger+SesTm=100+LogDir=..+MaxCur=5"
===================
我不知道sqlNet=ORCL应该怎么设置?
二、TUXEDO的配置
1、修改$TUXDIR/udataobj/RM文件
把原来的以Oracle_XA: xaosw:开头的屏蔽掉、
添加Oracle_XA: xaosw: -L${ORACLE_HOME}/lib -lclntsh
2、创建TMS文件:TMS_ORA10g,TUXEDO通过TMS_ORA10g与ORACLE数据库采用XA协议进行通讯
buildtms -o $TUXDIRbinTMS_ORA10g -r Oracle_XA
====================
以上这些,我也做过了,不过我用的用户是oracle,所以我的buildtms命令是:buildtms /home/oracle/simpapp/TMS_ORA10 -r Oracle_XA
[ 本帖最后由 simhare 于 2009-6-28 11:28 编辑 ]
用sysdba帐户登陆,
SQL> conn / as sysdba
SQL> @$ORACLE_HOME/rdbms/admin/xaview.sql
DROP VIEW v$xatrans$
*
ERROR at line 1:
ORA-00942: table or view does not exist
DROP VIEW v$pending_xatrans$
*
ERROR at line 1:
ORA-00942: table or view does not exist
View created.
View created.
SQL> grant select on v$xatrans$ to public with grant option;
Grant succeeded.
SQL> grant select on v$pending_xatrans$ to public with grant option;
Grant succeeded.
SQL> grant select any table to public;
Grant succeeded.
==================
以上这些我都做过了。
------------------
后来我选择了XA的通讯方式:
=================
请问在OpenInfo一节的sqlNet=Orcl
这里的Orcl是别人的配置,我应该怎么找出自己的配置呢?
===========
---------------
试了很多方法,都不通。一直是用tmboot时就failed。
---------------
有人说"在tpsvrinit()中打开数据库!"
============================
怎么"在tpsvrinit()中打开数据库!"?
我是这么做的:
tpsvrinit(int argc,char *argv[])
{
EXEC SQL BEGIN DECLARE SECTION;
char *uid="pw/pw@wilson";
float salary;
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT :uid;
if(tpopen()==-1){
printf("error to connect to oracle!n");
}
printf("the oracleserv successfully to connect to db2 in linux!n");
return 0;
}
这样可以吗?
一试便知。