Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: oci connect_string & c
Hello Jesse,
here is a example from our kernel routine AlligatorSQL. I have extract the connect for you in OCI8.
Hope that help ? - otherwise contact me at m.peter_at_alligatorsql.de
Manfred
(Alligator Company GmbH)
http://www.alligatorsql.com
sDatabase.Format("%s", database); sDatabase.TrimRight(); sDatabase.TrimLeft();
this->m_sMainUser.Format("%s", username); this->m_sMainDatabase.Format("%s", database); this->m_sMainAlias.Format("", 0);
sword status;
if(state == connected) {
// this object is already connected
LOGOUTPUT("Connection already established");
return (CONERR_ALRCON);
}
/*******************************************************//* set attribute server context in the service context */
/*******************************************************/OCIAttrSet((dvoid *)m_svchp, OCI_HTYPE_SVCCTX, (dvoid *)m_srvhp,
OCIHandleAlloc((dvoid *)m_envhp, (dvoid **)&m_authp,
(ub4)OCI_HTYPE_SESSION, (size_t)0, (dvoid **)0);
OCIAttrSet((dvoid *)m_authp, (ub4)OCI_HTYPE_SESSION, (dvoid *)username,
(ub4)strlen((char *)username), (ub4)OCI_ATTR_USERNAME, m_errhp);
OCIAttrSet((dvoid *)m_authp, (ub4)OCI_HTYPE_SESSION, (dvoid *)password,
(ub4) strlen((char *)password),
(ub4)OCI_ATTR_PASSWORD, m_errhp);
if((status = OCILogon(m_envhp, m_errhp, &m_svchp, username,
(ub4)strlen((char *)username),
password, (ub4)strlen((char *)password), database, (ub4)strlen((char
*)database))) == OCI_SUCCESS) {
// successful login
theUser.Format("%s", username);
thePassword.Format("%s", password);
if(database[0] == '\0')
database = (OraText *)" ";
theDatabase.Format("%s", database);
state = connected;
// save statistic
theApp.IncreaseOracleConnect();
LOGOUTPUT("AOracleConnection::connect OCI8 -> Connection successfully
established");
}
else {
display_error();
CString s;
s.Format("AOracleConnection::connect OCI8 -> Error while connecting to
Oracle ErrorCode : %i", status);
LOGOUTPUT(s.GetBuffer(0));
}
return(status);
}
Jesse Waters <jcwaters_at_wfubmc.edu> schrieb in im Newsbeitrag:
ao1lur$1bu0$1_at_f1n1.spenet.wfu.edu...
> How do programmatically set the right connect_string using OCI? I see
that
> to set the username and password that I use OCIAttrSet but I don't know
the
> correct way to set the database to which I will connect. > > As an example when I login to sqlplus I must use: > sqlplus> username/password_at_connect_string > to get in. The connect_string points me to the right database. I know I > must do this in my c code as well I just do not know how. Any takers? > > Thankx, > Jesse. > >Received on Wed Oct 09 2002 - 16:08:17 CDT
![]() |
![]() |