以下是我的測試oci的例子!
#include
#include
#include
#include "oci.h"
static ociserver *srvhp;
static ocisession *p_session;
static ocienv *p_env;
static ocierror *p_err;
static ocisvcctx *p_svc;
static ocistmt *p_sql;
static ocidefine *p_dfn = (ocidefine *) 0;
static ocibind *p_bnd = (ocibind *) 0;
int main()
printf("ssss/n");
rc = ociattrset(p_session,oci_htype_session,(text *)usrname,strlen(usrname),oci_attr_username,p_err);
if (rc != 0)
printf("111/n");
rc = ociattrset(p_session,oci_htype_session,(text *)password,strlen(password),oci_attr_password,p_err);
if (rc != 0)
printf("2222/n");
rc = ociserverattach(srvhp,p_err,(text *)"192.168.1.201",strlen("192.168.1.201"),oci_default);
if (rc != 0)
printf("3333/n");
rc = ocisessionbegin(p_svc,p_err,p_session,oci_cred_rdbms,oci_default);
if (rc != 0)
printf("sssss/n");
rc = ociattrset(p_svc,oci_htype_svcctx,p_session,(ub4)0,oci_attr_session,p_err);
if (rc != 0)
printf("tttt/n");
/* allocate and prepare sql statement */
rc = ocihandlealloc( (dvoid *) p_env, (dvoid **) &p_sql,
oci_htype_stmt, (size_t) 0, (dvoid **) 0);
if (rc != 0)
// text mysql[255];
// memset(mysql,0,255);
/* int usrid;
char pass[7];
scanf("%d",&usrid);
scanf("%s",pass);
sprintf(mysql,"insert into usermain(userid,password) values(%d,'%s')",usrid,pass);
rc = ocistmtprepare(p_sql, p_err, "insert into usermain values(11249,'tom','123456',123,'ddfdsaf')",
(ub4) strlen("insert into usermain values(12348,'tom','123456',123,'ddfdsaf')"), (ub4) oci_ntv_syntax, (ub4) oci_default);
if (rc != 0)
*/text *mysql = (text *) "select password from usermain where userid=4567";
// text *mysql = (text *) "update usermain set password='111111' where userid=1234";
// text *mysql = (text *) "delete from usermain where userid=1234";
rc = ocistmtprepare(p_sql, p_err, mysql,(ub4) strlen(mysql), (ub4) oci_ntv_syntax, (ub4) oci_default);
if (rc != 0)
/* bind the values for the bind variables */
// p_bvi = 10; /* use deptno=10 */
//rc = ocibindbyname(p_sql, &p_bnd, p_err, (text *) ":x",
// -1, (dvoid *) &p_bvi, sizeof(int), sqlt_int, (dvoid *) 0,
// (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, oci_default);
/* define the select list items */
rc = ocidefinebypos(p_sql, &p_dfn, p_err, 1, (dvoid *) p_sli,
(sb4)9, sqlt_chr, (dvoid *) 0, (ub2 *)0,
(ub2 *)0, oci_default);
if (rc != 0)
/* execute the sql statment */
rc = ocistmtexecute(p_svc, p_sql, p_err, (ub4)1,(ub4) 0, (ocisnapshot *) null, (ocisnapshot *) null,
(ub4) oci_commit_on_success);
if(rc != oci_no_data)
else
printf("over!/n");
rc = ociserverdetach(srvhp,p_err,oci_default); /* disconnect */
rc = ocihandlefree((dvoid *) p_sql, oci_htype_stmt); /* free handles */
rc = ocihandlefree((dvoid *) p_svc, oci_htype_svcctx);
rc = ocihandlefree((dvoid *) p_err, oci_htype_error);
return;
}
mysql遠端連線設定 MySQL遠端連線設定
這只是乙個簡單mysql設定。但很多圖簡單,卻忽略了安全性。所以對設定中的細節和含義需要弄到清清楚楚才行。這只是乙個簡單mysql設定。但很多圖簡單,卻忽略了安全性。所以對設定中的細節和含義需要弄到清清楚楚才行。mysql遠端連線的設定問題 下面是步驟 1 登陸本地的mysql server mys...
mysql 遠端連線失敗 mysql 遠端連線失敗
一 mysql 禁止 ip 遠端連線 mysql 庫 user表中 host 為 localhost 修改為 允許所有 ip 連線 或者 新增一條資料 host 為允許連線的 ip 二 授權某個使用者可以遠端連線 以root為例 grant all privileges on to root ide...
mysql遠端連線條件 MySql 遠端連線的條件
1 首先看伺服器防火牆 引用 centos 7.0預設使用的是firewall作為防火牆,使用iptables必須重新設定一下 1 直接關閉防火牆 systemctl stop firewalld.service 停止firewall systemctl disable firewalld.serv...