OCCI

1. OCCI - ORA-24550
在使用occi多线程访问oralce服务器的时候, 会出现ORA-24550 错误, 错误信息如下:
ORA-24550 : signal received : [si_signo=11] [si_errno=0] [si_code=50] [si_adr =
2020202020202020] killed
该错误会导致进程终止, 修改方案如下:
 
1. 1使用fifind命令所有oracle服务器端的 sqlnet.ora 文件, 在文件中添加下配置项:
DIAG_ADR_ENABLED=OFF
DIAG_SIGHANDLER_ENABLED=FALSE
DIAG_DDE_ENABLED=FALSE
 
 
1.2 如果该问题还未解决, 在调用 OCCI 接口的客户端对应oracle目录中, 例如, 我的客户端对用的oralce目录为
/opt/instantclient_11_2 , 在该目录下的 network/admin 中添加文件 sqlnet.ora , 内容如下:
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES,HOSTNAME)
DIAG_ADR_ENABLED=OFF
DIAG_SIGHANDLER_ENABLED=FALSE
DIAG_DDE_ENABLED=FALSE
 
2 数据库中插入日期类型
1. 字段的类型是: DATE
"2018-05-20 16:57:34"
to_date(日期字符串, 格式)
- 格式的指定: yyyy-mm-dd hh24:mi:ss
to_date('2018-05-20 16:57:34', 'yyyy-mm-dd hh24:mi:ss')  oracle的日期函数跟mysql的日期函数不一样的
 
3.代码    (这些都是常规步骤,会用就行了) 

#include <iostream>
#include <occi.h>
#include <string>
#include <stdlib.h>
#include <string.h>
using namespace std;
using namespace oracle::occi;

int main()
{
//初始化环境
Environment *env = Environment::createEnvironment();
if (env == NULL)
{
cout << "createEnvironment error" << endl;
return -1;
}

//连接oracle数据库
string usr = "scott";
string passwd = "tiger";
string connstr = "192.168.10.145:1521/orcl";
Connection *conn = env->createConnection(usr, passwd, connstr);
if (conn == NULL)
{
cout << "connect database error" << endl;
return -1;
}

//执行插入操作
Statement *stmt = conn->createStatement("insert into dept values(79, 'nongwu', 'tianjin')");
stmt->executeUpdate();

//sql语句中不要有分号
/*string stmt = "insert into dept values(109, 'lajiao', 'JYL_SC')";
Statement *stmt = conn->createStatement(sql);
stmt->execute();*/

string stmt = "delete from dept where deptno=99";
Statement *stmt = conn->createStatement(sql);
stmt->executeUpdate();    //stmt->execute(); 都可以用

 

 

 

//关闭数据库连接
env->terminateConnection(conn);

//关闭释放资源
Environment::terminateEnvironment(env);

return 0;
}

 
posted @   咖喱给给啊  阅读(228)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示