VC8 + OCCI 连接oracle 11g(11.2)

请教一下高手:

小弟最近在用vc8(vc2005)+occi连接oracle数据库时客户端的配置存在问题,老是连接不上。我的配置步骤是这样的,

首先下载instant client ,然后下载sdk,解压instant client 到目录C:/instantclient_11_2,然后解压sdk到同一个目

录,然后在安装了oracle11g的服务器上下载oci下面的lib文件和dll文件,将oraocci11.dll,oraocci11d.dll,oraocci11.sym

oraocci11d.sym放在C:/instantclient_11_2/VC8/目录下,把oraocci11.lib,oraocci11d.lib放在C:/instantclient_11_2/sdk/lib/msvc/vc8/目录下,然后设置环境变量为:C:/instantclient_11_2/VC8;C:/instantclient_11_2

在打开vc2005在选项中设置include和库文件目录。然后调试,代码如下:

 

const string userName = "ugprs";

        const string password = "Sys123456";

        const string connectString = "//192.168.0.133:1521/gprs";

 

oracle::occi::Environment *env = oracle::occi::Environment::createEnvironment("ZHS16GBK","UTF8");

        {

            Connection *conn = env->createConnection(

            userName, password,connectString);     

            Statement *stmt = conn->createStatement("select fid,fdesc_l2,fdesc_l3 from t_bas_param");

            ResultSet *rs = stmt->executeQuery();

            while (rs->next())

            {

                string l1=rs->getString(1);

                string l2=rs->getString(2);

                string l3=rs->getString(3);

                cout <<"表空间名称:"<<l1<<"  内容:"<<l2<<"  日志:"<<l3<<endl;

            } 

            stmt->closeResultSet(rs);

            conn->terminateStatement(stmt);

            env->terminateConnection(conn);

        }

        oracle::occi::Environment::terminateEnvironment(env);

    }

    catch (SQLException &sqlExcp)

    {

int error = sqlExcp.getErrorCode();

cout<<"Error code:"<<error<<endl;   

    }

在这句上出现异常:

 

Connection *conn = env->createConnection(

            userName, password,connectString);

错误码为24960,现在怎么调试都调不通,那位高手能给解决一下!

 

 

 

你可能感兴趣的:(oracle,数据库,String,dll,include,oracle11g)