源代码
C++ 代码
1. #include <iostream>
2. #include <string>
3. #include "occi.h"
4. using namespace oracle::occi;
5. using namespace std;
6.
7. int main()
8. {
9. string usr="sys";
10. string pwd="orcl";
11. string SID="ORCL"; // 注意大小写
12. string date;
13.
14. Environment *env=Environment::createEnvironment(Environmen
t::OBJECT);
15. Connection *conn= env->createConnection(usr,pwd,SID);//all stri
ngs
16. if(conn)
17. cout<<"success createConnection!"<<endl;
18. else
19. cout<<"failure createConnection!"<<endl;
20.
21. Statement *stmt = conn->createStatement();
22. string sSQL = "select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss
') from dual";
23. stmt->setSQL(sSQL);
24.
评论0
最新资源