您的位置:首页 > 数据库 > Oracle

OTL连接Oracle-连接方式

2015-10-29 11:27 399 查看
otl_connect db;
otl_connect::otl_initialize(true);	//OTL连接数据库设置

try
{
string strConn = "";
//strConn = "ordsys/annet@orcltest207a";			//需要在TNS中配好IP和端口
strConn = "ordsys/annet@120.25.148.207:1521/orcltest207a";			//可以不依赖TNS
//strConn = "driver={Oracle}; server=(120.25.148.207);database=orcltest207a;uid=ordsys;pwd=annet";//没成功

db.rlogon(strConn.c_str()); // 连接到本地Oracle    账号/密码@数据库名
}
catch ( otl_exception& p )
{
cout<<"error"<<endl;
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

return false;
}
otl_stream o(1, strsql.c_str(), db);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: