本文整理汇总了C++中otl_connect::logoff方法的典型用法代码示例。如果您正苦于以下问题:C++ otl_connect::logoff方法的具体用法?C++ otl_connect::logoff怎么用?C++ otl_connect::logoff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类otl_connect
的用法示例。
在下文中一共展示了otl_connect::logoff方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
otl_connect::otl_initialize(); // initialize ODBC environment
try{
db1.rlogon("UID=scott;PWD=tiger;DSN=freetds_mssql"); // connect to ODBC
db2.rlogon("UID=scott;PWD=tiger;DSN=freetds_mssql"); // connect to ODBC
db3.rlogon("UID=scott;PWD=tiger;DSN=freetds_mssql"); // connect to ODBC
db2.set_transaction_isolation_level(otl_tran_read_uncommitted);
db3.set_transaction_isolation_level(otl_tran_read_committed);
otl_cursor::direct_exec
(
db1,
"drop table test_tab",
otl_exception::disabled // disable OTL exceptions
); // drop table
otl_cursor::direct_exec
(
db1,
"create table test_tab(f1 int, f2 varchar(30))"
); // create table
db1.commit(); // committing the DDLs to the database
insert(); // insert records into table
cout<<"=======> Reading uncommitted data..."<<endl;
select_nolock(db2); // select records from table
db1.commit(); // committing the inserted rows to the database
cout<<"=======> Reading committed data..."<<endl;
select_committed(db3); // select records from table
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.sqlstate<<endl; // print out SQLSTATE message
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db1.logoff(); // disconnect from ODBC
db2.logoff(); // disconnect from ODBC
db3.logoff(); // disconnect from ODBC
return 0;
}
示例2: main
int main()
{
otl_connect::otl_initialize(); // initialize ODBC environment
try{
db.rlogon("uid=scott;pwd=tiger;dsn=mssql2008"); // connect to ODBC
otl_cursor::direct_exec
(
db,
"drop table test_tab",
otl_exception::disabled // disable OTL exceptions
); // drop table
otl_cursor::direct_exec
(
db,
"create table test_tab(f1 int, f2 varchar(30), f3 text)"
); // create table
select(); // select records from table
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from ODBC
return 0;
}
示例3: main
int main()
{
otl_connect::otl_initialize(); // initialize ODBC environment
try{
db.rlogon("scott/[email protected]"); // connect to ODBC
db.auto_commit_on();
otl_cursor::direct_exec(db,"drop procedure my_proc",0);
otl_cursor::direct_exec
(db,
"CREATE PROCEDURE my_proc "
" @A int out, "
" @B varchar(60) out, "
" @C varchar(60) "
"AS "
"BEGIN "
" SELECT @[email protected]+1"
" SELECT @[email protected] "
"END"
); // create stored procedure
stored_proc(); // invoking stored procedure
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.code<<endl; // print out error code
cerr<<p.var_info<<endl; // print out the variable that caused the error
cerr<<p.sqlstate<<endl; // print out SQLSTATE message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
}
db.logoff(); // disconnect from the data source
return 0;
}
示例4: main
int main()
{
otl_connect::otl_initialize(); // initialize DB2 CLI environment
try{
db.rlogon("scott/[email protected]"); // connect to DB2
otl_cursor::direct_exec
(db,
"drop table test_tab",
otl_exception::disabled // disable OTL exceptions
); // drop table
otl_cursor::direct_exec
(db,
"create table test_tab "
"(f1 int, f2 varchar(30), f3 int, f4 timestamp, f5 date, f6 time)"
); // create table
insert(); // insert records into table
select(); // select records from table
db.logoff(); // disconnect from DB2
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
return 0;
}
示例5: main
int main()
{
otl_connect::otl_initialize(); // initialize the database API environment
try{
db<<"scott/[email protected]"; // connect to the database
// Send SQL statements to the connect obejct for immediate execution.
// Ignore any exception for the first statement.
try{ db<<"drop table test_tab"; } catch(otl_exception&){}
db<<"create table test_tab(f1 int, f2 varchar(30))";
insert(); // insert records into table
select(); // select records from table
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from the database
return 0;
}
示例6: main
int main()
{
otl_connect::otl_initialize(); // initialize Informix CLI environment
try{
db.rlogon("informix/[email protected]"); // connect to Informix
otl_cursor::direct_exec
(
db,
"drop table test_tab",
otl_exception::disabled // disable OTL exceptions
); // drop table
otl_cursor::direct_exec
(
db,
"create table test_tab(f1 int, f2 varchar(30), f3 byte)"
); // create table
select(); // select records from table
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from Informix
return 0;
}
示例7: main
int main()
{
otl_connect::otl_initialize(); // initialize the database API environment
try{
db.rlogon("scott/[email protected]"); // connect to the database
otl_cursor::direct_exec
(
db,
"drop table test_tab",
otl_exception::disabled // disable OTL exceptions
); // drop table
db.commit();
otl_cursor::direct_exec
(
db,
"create table test_tab(f1 int, f2 ntext)"
); // create table
insert(); // insert records into table
select(); // select records from table
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from the database
return 0;
}
示例8: main
int main(int argc,char *argv[])
{
otl_connect::otl_initialize();
try{
db.rlogon("casshern/[email protected]");
otl_cursor::direct_exec(
db,
"drop table test_tab",
otl_exception::disabled
);
otl_cursor::direct_exec(
db,
"create table test_tab(f1 int,f2 varchar(11))"
);
insert();
select();
} catch(otl_exception& p) {
cerr << p.msg << endl;
cerr << p.stm_text << endl;
cerr << p.var_info << endl;
}
db.logoff(); //disconnect from the database
return 0;
}
示例9: main
int main()
{
otl_connect::otl_initialize(); // initialize OCI environment
try{
db<<"scott/tiger"; // connect to the database
// Send SQL statements to the connect obejct for immediate execution.
// Ignore any exception for the first statement.
try{ db<<"drop table test_tab"; } catch(otl_exception&){}
db<<"create table test_tab(f1 int, f2 clob)";
db<<"CREATE OR REPLACE PROCEDURE insert_proc "
" (A in NUMBER, "
" B in out nocopy CLOB) "
"IS "
"BEGIN "
" insert into TEST_TAB (F1, F2) "
" values (a, EMPTY_CLOB()) "
" returning F2 into B; "
"END;";
db<<"CREATE OR REPLACE PROCEDURE update_proc "
" (A in NUMBER, "
" B in out nocopy CLOB) "
"IS "
"BEGIN "
" select F2 "
" into B "
" from TEST_TAB "
" where F1 = A "
" for update nowait; "
"END;";
db<<"CREATE OR REPLACE PROCEDURE select_proc "
" (A in NUMBER, "
" B in out nocopy CLOB) "
"IS "
"BEGIN "
" select F2 "
" into B "
" from TEST_TAB "
" where f1 = A; "
"END;";
insert(); // insert records into table
update(); // update records in table
select(1); // select records from table
select(2); // select records from table
select(3); // select records from table
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from Oracle
return 0;
}
示例10: main
int main()
{
otl_connect::otl_initialize(); // initialize ODBC environment
try{
main_db.rlogon("scott/[email protected]_sybsql"); // connect to ODBC
main_db.auto_commit_off();
otl_cursor::direct_exec
(
main_db,
"drop table test_tab",
otl_exception::disabled // disable OTL exceptions
); // drop table
otl_cursor::direct_exec
(
main_db,
"create table test_tab(f1 int, f2 varchar(30))"
); // create table
insert(); // insert records into table
// opening a secondary connect
secondary_db.rlogon
(main_db.get_connect_struct().get_henv(), // environment handle to the main database connect
main_db.get_connect_struct().get_hdbc() // database connect handle to the main database connect
); // connect to ODBC
select(); // select records from table
// releasing the secondary connect
secondary_db.logoff();
}catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.sqlstate<<endl; // print out SQLSTATE message
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
main_db.logoff(); // disconnect from ODBC
return 0;
}
示例11: main
int main()
{
otl_connect::otl_initialize(); // initialize DB2-CLI environment
try{
db.rlogon("scott/[email protected]"); // connect to DB2
otl_cursor::direct_exec
(
db,
"drop table test_tab",
otl_exception::disabled // disable OTL exceptions
); // drop table
otl_cursor::direct_exec
(
db,
"create table test_tab(f1 int, f2 varchar(30))"
); // create table
otl_cursor::direct_exec
(db,
"DROP PROCEDURE my_proc2",
otl_exception::disabled // disable OTL exceptions
); // drop procedure and ignore any errors
otl_cursor::direct_exec
(db,
"CREATE PROCEDURE my_proc2(IN in_f1 INTEGER) "
"LANGUAGE SQL "
"RESULT SETS 1 "
"BEGIN "
" DECLARE c1 CURSOR WITH RETURN FOR "
" SELECT f1,f2 "
" FROM test_tab "
" WHERE f1 BETWEEN in_f1 AND in_f1*2; "
" OPEN c1; "
"END "
); // create stored procedure
insert(); // insert records into table
select(); // select records from table
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.sqlstate<<endl; // print out SQLSTATE message
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from DB2
return 0;
}
示例12: main
int main()
{
otl_connect::otl_initialize(); // initialize the database environment
try{
db.rlogon("scott/tiger"); // connect to the database
otl_cursor::direct_exec
(
db,
"drop table test_tab",
otl_exception::disabled // disable OTL exceptions
); // drop table
otl_cursor::direct_exec
(
db,
"create table test_tab(f1 int, f2 varchar(30))"
); // create table
insert(); // insert records into table
}
catch(my_base_exception& ex){ // intercept the base exception
if(ex.getType()==DB_BASE_EXCEPTION){
// "database exception" is recognized
// here, the otl_exception can be analyzed, or simply printed out
cerr<<"Database exception:"<<endl;
cerr<<"Code: "<<ex.getErrorCode()<<endl; // print out error code
cerr<<"Message: "
<<reinterpret_cast<const char*>(ex.getErrorMessage())
<<endl; // print out the error message
cerr<<"SQL Stm: "
<<ex.getErrorSQLStm()
<<endl; // print out the SQL Statement
cerr<<"Var Info: "
<<ex.getErrorVarInfo()
<<endl; // print out the bind variable information
if(ex.getErrorCode()==32005){
// OTL defined exception
cerr<<"Large Input String: "
<<ex.getErrorLargeString()
<<endl;
}
}else{
// otherwise, do something else
cerr<<"Base exception was caught..."<<endl;
}
}
db.logoff(); // disconnect from the database
return 0;
}
示例13: main
int main()
{
otl_connect::otl_initialize(); // initialize OCI environment
try{
db.rlogon("scott/tiger"); // connect to Oracle
otl_cursor::direct_exec
(db,
"CREATE OR REPLACE PACKAGE pkg_test IS "
" TYPE my_numeric_table IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; "
" TYPE my_varchar_table IS TABLE OF VARCHAR2(128) INDEX BY BINARY_INTEGER; "
" /* size is defined in bytes for Oracle 8i... */ "
" "
" PROCEDURE prc_test(v1 IN OUT my_numeric_table, v2 OUT my_varchar_table); "
" "
"END; "
);
otl_cursor::direct_exec
(db,
"CREATE OR REPLACE PACKAGE BODY pkg_test IS "
" "
" PROCEDURE prc_test(v1 IN OUT my_numeric_table, v2 OUT my_varchar_table) "
" IS "
" BEGIN "
" FOR i IN 1..v1.last LOOP "
" v1(i) := v1(i)+100; "
" END LOOP; "
" v1(v1.last+1) := 0; "
" v2(1) := 'Hello'; "
" v2(2) := 'World'; "
" v2(3) := '!!!'; "
" END; "
" "
"END; "
);
plsql();
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from Oracle
return 0;
}
示例14: main
int main()
{
otl_connect::otl_initialize(); // initialize ODBC environment
try{
db.rlogon("scott/[email protected]"); // connect to MS SQL Server
otl_cursor::direct_exec
(
db,
"drop table test_tab",
otl_exception::disabled // disable OTL exceptions
); // drop table
otl_cursor::direct_exec
(
db,
"create table test_tab(f1 int, f2 varchar(30))"
); // create table
otl_cursor::direct_exec
(
db,
"drop procedure my_proc",
otl_exception::disabled // disable OTL exceptions
); // drop old version of stored procedure, if there is one.
otl_cursor::direct_exec
(db,
"CREATE PROCEDURE my_proc "
" @F1 int "
"AS "
"SELECT * FROM test_tab "
"WHERE f1>[email protected] AND f1<[email protected]*2 "
); // create stored procedure
insert(); // insert records into table
select(); // select records from table
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.sqlstate<<endl; // print out SQLSTATE
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from MS SQL Server
return 0;
}
示例15: main
int main()
{
otl_connect::otl_initialize(); // initialize ODBC environment
try{
db.rlogon("SCOTT/[email protected]"); // connect to database
otl_cursor::direct_exec
(
db,
"drop table test_tab",
otl_exception::disabled // disable OTL exceptions
); // drop table
otl_cursor::direct_exec
(
db,
"create table test_tab(f1 int, f2 varchar(30))"
); // create table
otl_cursor::direct_exec
(
db,
"DROP PROCEDURE prc1",
otl_exception::disabled // disable OTL exceptions
);
otl_cursor::direct_exec
(
db,
"CREATE DBPROC prc1 (IN f1 int) "
"RETURNS CURSOR AS "
"$CURSOR = 'CUR1'; "
"DECLARE :$CURSOR CURSOR FOR "
"SELECT * FROM scott.test_tab WHERE f1 >= :f1 and f1 <= :f1*2; "
);
insert(); // insert records into the table
select(8); // select records from the table
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.sqlstate<<endl; // print out SQLSTATE message
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from ODBC
return 0;
}