Re: sqlplus v. OCI v. OCCI connect
Date: Fri, 1 May 2009 06:26:37 -0700 (PDT)
Message-ID: <6f960e08-9bee-4590-927c-42e83cf15b2b_at_x31g2000prc.googlegroups.com>
On Apr 30, 7:14 pm, Shane <gshanemil..._at_verizon.net> wrote:
> this command connects to oracle:
>
> $ sqlplus smiller/mill99_at_oradev
>
> A OTL based program which uses smiller/mill99_at_oradev as a connection
> string connects to Oracle.
> A working OCI program here which was gutted to use user=smiller,
> password=mill99, db=oradev connects to Oracle.
>
> But an OCCI program with this code:
>
> 52 Environment* const env = Environment::createEnvironment(
> 53 Environment::DEFAULT);
> 54
> 55 // Open a connection to the database, then close it.
> 56 //
> 58 try
> 59 {
> 60 Connection* const con = env->createConnection(user, pass,
> osid);
>
> throws on line 60 giving:
>
> Can't connect: ORA-01017: invalid username/password; logon denied
>
> What in the heck is the deal with OCCI? My OTL code worked the first
> time, no problem. I guess OTL is based on OCI, which works How is
> connecting to the db with OCCI so different from OCI, OTL, sqlplus?
> How can I fix this error?
>
> tnsping oradev gives:
>
> $ tnsping oradev
>
> TNS Ping Utility for Solaris: Version 10.2.0.3.0 - Production on 30-
> APR-2009 19:11:28
>
> Copyright (c) 1997, 2006, Oracle. All rights reserved.
>
> Used parameter files:
>
> Used TNSNAMES adapter to resolve the alias
> Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =
> (PROTOCOL = TCP)(HOST = sundev16)(PORT = 28538))) (CONNECT_DATA =
> (SERVICE_NAME = oradev.bloomberg.com)))
> OK (10 msec)
I found this in the OracleŽ C++ Call Interface Programmer's Guide 10g Release 2 (10.2) Part Number B14294-01, Ch 3
>>
const string userName = "SCOTT"; const string password = "TIGER"; const string connectString = "";
Environment *env = Environment::createEnvironment(); {
Connection *conn = env->createConnection(
userName, password, connectString); Statement *stmt = conn->createStatement(
"SELECT blobcol FROM mytable");
ResultSet *rs = stmt->executeQuery();
rs->next();
Blob b = rs->getBlob(1);
cout << "Length of BLOB : " << b.length();
. . .
stmt->closeResultSet(rs);
conn->terminateStatement(stmt);
env->terminateConnection(conn);
}
Environment::terminateEnvironment(env);
<<
I do not know if this will help or not. I would think that connectString would need a value and under a section labeled Database Connection Names for Instant Client in ch 2 there are several formats given including //host:[port][/service name] and a note about using an entry from tnsnames.ora file.
HTH -- Mark D Powell -- Received on Fri May 01 2009 - 08:26:37 CDT