📄 ora2my.h
字号:
#ifndef __ORA2MY_H_
#define __ORA2MY_H_
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#define BUF_SIZE 128*1024
#define BLOB_SIZE 128*1024
//OTL include
#define OTL_ORA9I
#define OTL_STL
#include "otlv4.h"
//ACE include
#include "ace/Thread_Mutex.h"
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_strings.h"
#include "ace/Get_Opt.h"
#include "ace/Null_Mutex.h"
#include "ace/SOCK_Acceptor.h"
#include "ace/Singleton.h"
#include "ace/SString.h"
#include "ace/Thread_Mutex.h"
#include "ace/Configuration.h"
#include "ace/Configuration_Import_Export.h"
#include "ace/Task.h"
#include "ace/FILE_Addr.h"
#include "ace/FILE_Connector.h"
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_sys_stat.h"
#include "ace/OS_NS_ctype.h"
#include "ace/streams.h"
#include "ace/Log_Msg.h"
#include "ace/OS_main.h"
#include "ace/OS_Memory.h"
#include "ace/Guard_T.h"
#include "ace/Log_Msg.h"
#include "ace/Thread_Mutex.h"
#include "mysql.h"
#include "zlib.h"
class Z_Stream
{
public:
Z_Stream(int level=Z_DEFAULT_COMPRESSION):have(0)
{
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
(void)deflateInit(&strm, level);
};
inline int deFlate(unsigned char *out,int *out_len,unsigned char *in,int in_len , int flush)
{
strm.avail_in = in_len;
strm.next_in = in;
do {
//printf("--------\n");
strm.avail_out = *out_len;
strm.next_out = out;
if(deflate(&strm, flush) == Z_STREAM_ERROR)
{
return Z_ERRNO;
}
have = *out_len - strm.avail_out;
*out_len = have;
} while (strm.avail_out == 0);
return Z_OK;
};
~Z_Stream()
{
(void)deflateEnd(&strm);
};
private:
int flush;
unsigned have;
z_stream strm;
};
struct space
{
char* buf_;
u_long len_;
};
class ora2my
{
public:
ora2my(void);
~ora2my(void);
public:
int init_ora(ACE_TString login);
int init_my(ACE_TString host, ACE_TString user, ACE_TString pwd, u_int port, ACE_TString tablename);
int connect_ora(void);
int connect_my(void);
int dumpfromoracle(ACE_TString sql);
int countlob(otl_column_desc* desc, int fieldcount);
bool VerifyStmt(ACE_TString sql, size_t lobcount);
bool BindParam(MYSQL_BIND *bind);
bool Execute(void);
int insert2mysql(ACE_TString sql, size_t lobcount, ACE_TString tablename, MYSQL_BIND *bind);
private:
ACE_TString ora_login_;
otl_connect ora_db_;
//otl_lob_stream ora_stream_;
private:
ACE_TString my_host_;
ACE_TString my_user_;
ACE_TString my_pwd_;
u_int my_port_;
ACE_TString my_tabname_;
MYSQL* mysql_;
MYSQL_STMT *stmt_;
private:
//char** buffer_;
size_t blobcount_;
space * buffer_;
};
typedef ACE_Singleton<ora2my, ACE_Thread_Mutex> ORA2MYSQL;
#endif /*__ORA2MY_H_*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -