网站首页 > 文章中心 > 其它

oracle应用怎么写

作者:小编 更新时间:2023-09-05 13:10:14 浏览量:249人看过

oracle 主备切换 应用需要怎么写

主库增加一个浮动IP,这个IP是应用连接的地址. dg主备如果发生切换的话,这个浮动IP也跟着切换(自己写shell脚本了)

怎样使用OCI编写多线程的ORACLE应用软件

void* OracleProcess(GPS_DATA GpsRec) // 数据库数据处理

oracle应用怎么写-图1

{

interval = 0;

struct HashItem* pHash;

char tName[10] = {0}; // 表名字

int i,k;

int j = TotalRec RATE;

double distance;

for(i=0; i j; i++)

sprintf(temp,"%s%f%f%f%d",gps_last[i].tid,gps_last[i].lon,gps_last[i].lat,gps_last[i].speed,gps_last[i].udate);

}

for(i = 0; i TotalRec; i++)

for(k=0; kj; k++) // 查询车机是否在册

if(strcmp(GpsRec[i].tid,tid[k]) == 0)

break;

if(k j)

if(GpsRec[i].udate != 0.00)

distance = InfoUpdate(GpsRec,i); // 最新GPS数据更新

sprintf(temp,"%s%f%f%f%d",GpsRec[i].tid,GpsRec[i].lon,GpsRec[i].lat,GpsRec[i].speed,GpsRec[i].udate);

if (distance 0.0001)

sprintf(tName,"GPS_%d_Y",tf[k]);

sprintf(sql,"insert into %s (id,tm_id,lon,lat, speed, utc_time, udate,mileage,DIRECTION,DISTANCE) values (seq_gps.nextVal,'%s','%f','%f','%f','%d','%d','%f','%d','%f','%d')",

tName,GpsRec[i].tid,GpsRec[i].lon,GpsRec[i].lat,GpsRec[i].speed,GpsRec[i].utime,GpsRec[i].udate,GpsRec[i].mileage,GpsRec[i].dir,distance,interval);

printf("%s\n",sql);

oci_excu(oracle_env,(text *)sql,0); // 插入数据

memset(tName,0x00,10);

memset(GpsRec,0x00,sizeof(GpsRec));

free(pHash);

pthread_exit(NULL);

void TcpProcess(int tfd) // 处理TCP连接上的事务

struct timeval ntime;

int index = 0,times,ret;

int rlen = 0,rflag = 0;

while(1)

if(rlen = 0)

times = 0;

while(ret--)

if(tflag[tfd] == tfd) // 已经存在的socket

LOVENIX *info = (LOVENIX *)malloc(sizeof(LOVENIX));

memset(info,0x00,sizeof(LOVENIX));

ProtocolAnalysisLovenixTcp(recvbuf[times],info);

ProtocolAnalysisLovenixUdp(recvbuf[times],info);

sprintf(info-tid,"%s",seq[tfd]); // 合成车辆ID

DataProcess(info); // 处理GPS数据

free(info);

gettimeofday(ntime, NULL);

cntime[tfd] = ntime.tv_sec; // 更新时间

if(!rflag)

if((index = RegLovenix(tfd,recvbuf)) -1)

sprintf(seq[tfd],"%s",tid[index]); // 将对应的socket设备ID保存

sfd[tfd] = tfd;

cntime[tfd] = ntime.tv_sec;

tflag[tfd] = tfd;

rflag = 1;

memset(recvbuf,0x00,rlen);

void *TcpServer(void *arg)

int port = (unsigned int) arg;

int efd,i;

int listener, nfds, n, listen_opt = 1, lisnum;

struct sockaddr_in my_addr, their_addr;

socklen_t len = sizeof(their_addr);

lisnum = MAXLISTEN;

for(i=0; iMAX_REC; i++)

sfd[i] = 0;

tflag[i] = 0;

if ((listener = socket(PF_INET, SOCK_STREAM, 0)) == -1) // 开启 socket 监听

lprintf(lfd, FATAL, "TCP Socket error!\n");

exit(1);

else

lprintf(lfd, INFO, "TCP socket creat susscess!\n");

setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, (void *) listen_opt,(int) sizeof(listen_opt)); // 设置端口多重邦定

setnonblocking(listener);

bzero(my_addr, sizeof(my_addr));

my_addr.sin_family = PF_INET;

my_addr.sin_port = htons(port);

my_addr.sin_addr.s_addr = INADDR_ANY;

if (bind(listener, (struct sockaddr *) my_addr, sizeof(struct sockaddr)) == -1)

lprintf(lfd, FATAL, "TCP bind error!\n");

lprintf(lfd, INFO, "TCP bind susscess!\n");

if (listen(listener, lisnum) == -1)

lprintf(lfd, FATAL, "TCP listen error!\n");

lprintf(lfd, INFO, "TCP listen susscess!\n");

kdpfd = epoll_create(MAXEPOLLSIZE); // 创建 epoll句柄,把监听socket加入到epoll集合里

ev.events = EPOLLIN | EPOLLET; // 注册epoll 事件

ev.data.fd = listener;

if (epoll_ctl(kdpfd, EPOLL_CTL_ADD, listener, ev) 0)

lprintf(lfd, FATAL, "EPOLL_CTL_ADD error!\n");

while (1)

sem_wait(sem_tcp); // 等待 sem_TCP

sem_wait(sem_tp); // 将tp值减一

nfds = epoll_wait(kdpfd, events, MAXEPOLLSIZE, 1); // 等待有事件发生

if (nfds == -1)

lprintf(lfd, FATAL,"EPOLL_WAIT error!\n");

for (n = 0; n nfds; ++n) // 处理epoll所有事件

if (events[n].data.fd == listener) // 如果是连接事件

if ((efd = accept(listener, (struct sockaddr *) their_addr,len)) 0)

lprintf(lfd, FATAL, "accept error!\n");

continue;

lprintf(lfd, INFO, "Client from :%s\tSocket ID:%d\n", inet_ntoa(their_addr.sin_addr) ,efd);

setnonblocking(efd); // 设置新连接为非阻塞模式

ev.events = EPOLLIN | EPOLLET; // 注册新连接

ev.data.fd = efd;

if (epoll_ctl(kdpfd, EPOLL_CTL_ADD, efd, ev) 0) // 将新连接加入EPOLL的监听队列

cntime[efd] = ntime.tv_sec;

sfd[efd] = efd;

else if (events[n].events EPOLLIN)

tpool_add_work(pool, TcpProcess, (void*)events[n].data.fd); // 读取分析TCP信息

close(events[n].data.fd);

epoll_ctl(kdpfd, EPOLL_CTL_DEL, events[n].data.fd, ev);

sem_post(sem_cm);

sem_post(sem_udp);

close(listener);

int DataProcess(LOVENIX *info) // 处理GPS数据

if(sflag == 0 (CacheRec != TotalRec)) // 缓存1可用且没有满

gps_cache[CacheRec].lat = info-lat;

gps_cache[CacheRec].mileage = info-mileage;

gps_cache[CacheRec].lon = info-lon;

gps_cache[CacheRec].udate = atoi(info-udate);

gps_cache[CacheRec].utime = atoi(info-utime);

gps_cache[CacheRec].dir = atoi(info-dir);

sprintf(gps_cache[CacheRec].tid ,"%s",info-tid);

CacheRec++;

// printf("CacheRec %d\tTotalRec %d \t sflag:%d\n",CacheRec,TotalRec,sflag);

if(CacheRec == TotalRec)

sflag = 1;

pthread_attr_init(attr); // 初始化属性值,均设为默认值

pthread_attr_setscope(attr, PTHREAD_SCOPE_SYSTEM);

pthread_attr_setdetachstate(attr, PTHREAD_CREATE_DETACHED); // 设置线程为分离属性

if (pthread_create(thread, attr,(void*) OracleProcess,(void*)gps_cache)) // 创建数据处理线程

lprintf(lfd, FATAL, "oracle pthread_creat error!\n");

CacheRec = 0;

gps_cache1[Cache1Rec].mileage = info-mileage;

gps_cache1[Cache1Rec].lat = info-lat;

gps_cache1[Cache1Rec].lon = info-lon;

gps_cache1[Cache1Rec].udate = atoi(info-udate);

gps_cache1[Cache1Rec].utime = atoi(info-utime);

gps_cache1[Cache1Rec].dir = atoi(info-dir);

sprintf(gps_cache1[Cache1Rec].tid ,"%s",info-tid);

Cache1Rec++;

if(Cache1Rec == TotalRec)

sflag = 0;

if (pthread_create(thread, attr,(void*) OracleProcess,(void*)gps_cache1)) // 创建数据处理线程

Cache1Rec = 0;

lprintf(lfd, FATAL, "No cache to use!\n");

return (0);

return (1);

oracle 应用

第一章 ORACLE介绍

由于ORACLE数据库产品是当前数据库技术的典型代表,她的产品除了数据库系统外,还有应用系统、开发工具等.刚接触Oracle的人员都有这样的感觉:Oracle的产品太多,每个产品内容精深,不知道从哪儿开始学才好.为了用少量时间更好地理解和使用oracle 数据库系统,有必要对oracle的一些基本术语及概念进行了解,下面给出一些在管理中经常用到的概念和术语,供初学者快速了解Oracle数据库系统提供方便.

①对象/关系模型

.....................................

以上就是土嘎嘎小编为大家整理的oracle应用怎么写相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章