📄 occimb1.cpp
字号:
/* occimb1.cpp - OCCI Globalization Support demo program ----------------------------------------------------- Demonstrates OCCI globalization support capabilities :- 1.Multiple clients with different charactersets connecting and interacting with a single UTF8 database 2.createEnvironment() with multibyte charactersets. 3.using Statement::setString to bind multibyte data 4.Storing Chinese(ZHT16BIG5) & Greek(EL8ISO8859P7) data into a VARCHAR2 column. of a UTF8 database. 5.Retrieving the multi-lingual data in UTF8 characterset Demo schema : - table GlobalInfo_Tab ( G_LANG VARCHAR2(10), G_INFODESC VARCHAR2(50), G_INFO VARCHAR2(100), Chinese/Greek information ) This demo inserts some Chinese & Greek data in ZHT16BIG5 and EL8ISO8859P7 charactersets and then fetches them in UTF8 characterset. INSTRUCTIONS ------------ 1.Run SQL script - occimb1.sql before running this program. THE DATABASE CHARACTERSET MUST BE UTF8 FOR THE SQL AND DEMO PROGRAM TO RUN. TO CONVERT AN EXISTING DATABASE NON-UTF8 CHARACTER SET TO UTF8, USE "ALTER DATABASE CHARACTER SET" COMMAND FOR MORE INFO, PLEASE REFER "SQL REFERENCE" MANUAL 2.Run this program and direct output to a file and view the output file from a browser :- $ ./occimb1 > occimb1.html*/#include <iostream>#include <occi.h>using namespace std;using namespace oracle::occi;main(){ //part1 - use ZHT16BIG5 characterset try { cout << "Creating environment with ZHT16BIG5(Chinese) characterset <BR>" << endl; Environment *big5env = Environment::createEnvironment("ZHT16BIG5","ZHT16BIG5"); Connection *conn = big5env->createConnection("HR", "HR"); cout << "Inserting some information in Chinese - Periodic table elements <BR>" << endl; Statement *stmt = conn->createStatement("INSERT INTO GLOBALINFO_TAB VALUES (:1, :2 ,:3)"); stmt->setString(1,"Chinese"); stmt->setString(2,"Periodic Table Elements"); //the code-points in ZHT16BIG5 for the symbols const char siliconsym[] = {0xD6,0xBA,0x00}; const char goldsym[] = {0xAA,0xF7,0x00}; const char calciumsym[] = {0xE0,0xB3,0x00}; string info; info += "Silicon = "; info += siliconsym; info += " Gold = "; info += goldsym; info += " Calcium = "; info += calciumsym; stmt->setString(3,info); stmt->executeUpdate(); conn->commit(); conn->terminateStatement(stmt); big5env->terminateConnection(conn); Environment::terminateEnvironment(big5env); } catch (SQLException &e) { cout << "Error : "; cout << e.getMessage() << endl; } //part2 - use EL8ISO8859P7(Greek) characterset try { cout << "Now creating environment with EL8ISO8859P7(Greek) characterset <BR>" << endl; Environment *greekenv= Environment::createEnvironment("EL8ISO8859P7","EL8ISO8859P7"); Connection *conn = greekenv->createConnection("HR", "HR"); cout << "Inserting some information in Greek - Mathematical symbols <BR>" << endl; Statement *stmt = conn->createStatement("INSERT INTO GLOBALINFO_TAB VALUES (:1, :2 ,:3)"); stmt->setString(1,"Greek"); stmt->setString(2,"Mathematical symbols"); string info; info += "alpha = "; info += "
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -