⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connection_8c-source.html

📁 oci的源码,可以在任何平台上编译,相当方便实用
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00290"></a>00290     <a name="l00291"></a>00291     OCI_CALL2<a name="l00292"></a>00292     (<a name="l00293"></a>00293         res, con, <a name="l00294"></a>00294         <a name="l00295"></a>00295         OCIAttrSet((dvoid *) con-&gt;<a class="code" href="struct_o_c_i___connection.html#f20d1bea40e79481aeece933a4c70898">cxt</a>, (ub4) OCI_HTYPE_SVCCTX, <a name="l00296"></a>00296                    (dvoid *) con-&gt;<a class="code" href="struct_o_c_i___connection.html#5e5c78e07f642e570f44331b8e646b46">svr</a>, (ub4) sizeof (con-&gt;<a class="code" href="struct_o_c_i___connection.html#5e5c78e07f642e570f44331b8e646b46">svr</a>), <a name="l00297"></a>00297                    (ub4) OCI_ATTR_SERVER, con-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>)<a name="l00298"></a>00298     )<a name="l00299"></a>00299 <a name="l00300"></a>00300     <span class="comment">/* set session login attribute */</span><a name="l00301"></a>00301 <a name="l00302"></a>00302     if ((res == TRUE) &amp;&amp; (con-&gt;user != NULL) &amp;&amp; (con-&gt;user[0] != 0))<a name="l00303"></a>00303     {<a name="l00304"></a>00304         osize = -1;<a name="l00305"></a>00305         ostr  = OCI_GetInputMetaString(con-&gt;<a class="code" href="struct_o_c_i___connection.html#50a2a86abeb957f56d76ae872b2bfe9d">user</a>, &amp;osize);<a name="l00306"></a>00306 <a name="l00307"></a>00307         OCI_CALL2<a name="l00308"></a>00308         (<a name="l00309"></a>00309             res, con,<a name="l00310"></a>00310             <a name="l00311"></a>00311             OCIAttrSet((dvoid *) con-&gt;<a class="code" href="struct_o_c_i___connection.html#09c8704dbf6d868165925c788ef3274e">ses</a>,(ub4)  OCI_HTYPE_SESSION, <a name="l00312"></a>00312                        (dvoid *) ostr, (ub4) osize, <a name="l00313"></a>00313                        (ub4) OCI_ATTR_USERNAME, con-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>)<a name="l00314"></a>00314         )<a name="l00315"></a>00315 <a name="l00316"></a>00316         OCI_ReleaseMetaString(ostr);<a name="l00317"></a>00317     }<a name="l00318"></a>00318 <a name="l00319"></a>00319     <span class="comment">/* set session password attribute */</span><a name="l00320"></a>00320 <a name="l00321"></a>00321     if ((res == TRUE) &amp;&amp; (con-&gt;pwd != NULL) &amp;&amp; (con-&gt;pwd[0] != 0))<a name="l00322"></a>00322     {<a name="l00323"></a>00323         osize = -1;<a name="l00324"></a>00324         ostr  = OCI_GetInputMetaString(con-&gt;<a class="code" href="struct_o_c_i___connection.html#5ba3064a162ab1800c928d2805318872">pwd</a>, &amp;osize);<a name="l00325"></a>00325 <a name="l00326"></a>00326         OCI_CALL2<a name="l00327"></a>00327         (<a name="l00328"></a>00328             res, con,<a name="l00329"></a>00329             <a name="l00330"></a>00330             OCIAttrSet((dvoid *) con-&gt;<a class="code" href="struct_o_c_i___connection.html#09c8704dbf6d868165925c788ef3274e">ses</a>, (ub4) OCI_HTYPE_SESSION, <a name="l00331"></a>00331                        (dvoid *) ostr, (ub4) osize, <a name="l00332"></a>00332                        (ub4) OCI_ATTR_PASSWORD, con-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>)<a name="l00333"></a>00333         )<a name="l00334"></a>00334 <a name="l00335"></a>00335         OCI_ReleaseMetaString(ostr);<a name="l00336"></a>00336     }<a name="l00337"></a>00337 <a name="l00338"></a>00338     <span class="comment">/* start session */</span><a name="l00339"></a>00339     <a name="l00340"></a>00340     if (res == TRUE)<a name="l00341"></a>00341     {<a name="l00342"></a>00342         ub4 credt = OCI_CRED_RDBMS;<a name="l00343"></a>00343 <a name="l00344"></a>00344         <span class="keywordflow">if</span>  (((con-&gt;<a class="code" href="struct_o_c_i___connection.html#50a2a86abeb957f56d76ae872b2bfe9d">user</a> == NULL) || (con-&gt;<a class="code" href="struct_o_c_i___connection.html#50a2a86abeb957f56d76ae872b2bfe9d">user</a>[0] == 0)) &amp;&amp;<a name="l00345"></a>00345              ((con-&gt;<a class="code" href="struct_o_c_i___connection.html#5ba3064a162ab1800c928d2805318872">pwd</a>  == NULL) || (con-&gt;<a class="code" href="struct_o_c_i___connection.html#5ba3064a162ab1800c928d2805318872">pwd</a>[0]  == 0)))<a name="l00346"></a>00346         {<a name="l00347"></a>00347             credt = OCI_CRED_EXT;<a name="l00348"></a>00348         }<a name="l00349"></a>00349 <a name="l00350"></a>00350         OCI_CALL2<a name="l00351"></a>00351         (<a name="l00352"></a>00352             res, con,<a name="l00353"></a>00353             <a name="l00354"></a>00354             OCISessionBegin(con-&gt;<a class="code" href="struct_o_c_i___connection.html#f20d1bea40e79481aeece933a4c70898">cxt</a>, con-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>, con-&gt;<a class="code" href="struct_o_c_i___connection.html#09c8704dbf6d868165925c788ef3274e">ses</a>, credt, con-&gt;<a class="code" href="struct_o_c_i___connection.html#642ca8589aad1bcb1578c536e0d2d7ae">mode</a>)<a name="l00355"></a>00355         )<a name="l00356"></a>00356  <a name="l00357"></a>00357        <span class="comment">/* This call has moved after OCISessionBegin() call to enable connection</span><a name="l00358"></a>00358 <span class="comment">          pooling (an error ORA-24324 was thrown is the session handle was set to</span><a name="l00359"></a>00359 <span class="comment">          the service context handle before OCISessionBegin() */</span><a name="l00360"></a>00360     <a name="l00361"></a>00361         OCI_CALL2<a name="l00362"></a>00362         (<a name="l00363"></a>00363             res, con,<a name="l00364"></a>00364             <a name="l00365"></a>00365             OCIAttrSet((dvoid *) con-&gt;cxt, (ub4) OCI_HTYPE_SVCCTX, <a name="l00366"></a>00366                        (dvoid *) con-&gt;ses, (ub4) sizeof(con-&gt;ses), <a name="l00367"></a>00367                        (ub4) OCI_ATTR_SESSION, con-&gt;err))<a name="l00368"></a>00368 <a name="l00369"></a>00369     }<a name="l00370"></a>00370     <a name="l00371"></a>00371     <span class="comment">/* check for success */</span><a name="l00372"></a>00372 <a name="l00373"></a>00373     if (res == TRUE)<a name="l00374"></a>00374     {<a name="l00375"></a>00375         <span class="comment">/* get server version */</span><a name="l00376"></a>00376 <a name="l00377"></a>00377         <a class="code" href="group__g__connect.html#ged47a25a1f96fd630f176fe702ac443a" title="Return the connected database server version.">OCI_GetVersionServer</a>(con);<a name="l00378"></a>00378 <a name="l00379"></a>00379         <span class="comment">/* create default transaction object */</span><a name="l00380"></a>00380 <a name="l00381"></a>00381         con-&gt;trs  = <a class="code" href="group__g__transac.html#g206d14aa9a25befd218a7f91a56d5c47" title="Create a new global transaction or a serializable/read-only local transaction.">OCI_TransactionCreate</a>(con, 1, OCI_TRANS_READWRITE, NULL);<a name="l00382"></a>00382 <a name="l00383"></a>00383         <span class="comment">/* start transaction */</span><a name="l00384"></a>00384         <a name="l00385"></a>00385         res = <a class="code" href="group__g__transac.html#gf8e8d8d04d91f2c18dbf34d875b8e42f" title="Start global transaction.">OCI_TransactionStart</a>(con-&gt;trs);<a name="l00386"></a>00386     }<a name="l00387"></a>00387 <a name="l00388"></a>00388 <a name="l00389"></a>00389     <span class="comment">/* set OCILIB's driver layer name attribute */</span><a name="l00390"></a>00390 <a name="l00391"></a>00391 <span class="preprocessor">#if OCI_VERSION_COMPILE &gt;= OCI_11</span><a name="l00392"></a>00392 <span class="preprocessor"></span><a name="l00393"></a>00393     <span class="keywordflow">if</span> ((res == TRUE) &amp;&amp; (OCILib.ver_runtime &gt;= OCI_11) &amp;&amp; (con-&gt;<a class="code" href="struct_o_c_i___connection.html#a1557af9d91979e54d5420bd3e2a9b65">ver_maj</a> &gt;= OCI_11))<a name="l00394"></a>00394     {<a name="l00395"></a>00395         osize = -1;<a name="l00396"></a>00396         ostr  = OCI_GetInputMetaString(OCILIB_DRIVER_NAME, &amp;osize);<a name="l00397"></a>00397 <a name="l00398"></a>00398         OCI_CALL2<a name="l00399"></a>00399         (<a name="l00400"></a>00400             res, con,<a name="l00401"></a>00401             <a name="l00402"></a>00402             OCIAttrSet((dvoid *) con-&gt;<a class="code" href="struct_o_c_i___connection.html#09c8704dbf6d868165925c788ef3274e">ses</a>, (ub4) OCI_HTYPE_SESSION, <a name="l00403"></a>00403                        (dvoid *) ostr, (ub4) osize, <a name="l00404"></a>00404                        (ub4) OCI_ATTR_DRIVER_NAME, con-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>)<a name="l00405"></a>00405         )<a name="l00406"></a>00406 <a name="l00407"></a>00407         OCI_ReleaseMetaString(ostr);<a name="l00408"></a>00408     }<a name="l00409"></a>00409 <a name="l00410"></a>00410 <span class="preprocessor">#endif</span><a name="l00411"></a>00411 <span class="preprocessor"></span><a name="l00412"></a>00412 <a name="l00413"></a>00413    <span class="comment">/* update internal status */</span><a name="l00414"></a>00414     <a name="l00415"></a>00415     <span class="keywordflow">if</span> (res == TRUE)<a name="l00416"></a>00416     {<a name="l00417"></a>00417         <span class="keywordflow">if</span> (OCILib.ver_runtime &lt; OCI_9 &amp;&amp; con-&gt;<a class="code" href="struct_o_c_i___connection.html#63a53de950b2cce15ff16958470d2c31">pool</a> != NULL)<a name="l00418"></a>00418             con-&gt;<a class="code" href="struct_o_c_i___connection.html#63a53de950b2cce15ff16958470d2c31">pool</a>-&gt;<a class="code" href="struct_o_c_i___conn_pool.html#eeacb1dbd6dce15eaf01e8413dbb06e9">nb_busy</a>++;<a name="l00419"></a>00419 <a name="l00420"></a>00420         con-&gt;<a class="code" href="struct_o_c_i___connection.html#25639578bd259929189e6b842598a187">cstate</a> = OCI_CONN_LOGGED;<a name="l00421"></a>00421     }<a name="l00422"></a>00422 <a name="l00423"></a>00423     <span class="keywordflow">return</span> res;<a name="l00424"></a>00424 }<a name="l00425"></a>00425 <a name="l00426"></a>00426 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00427"></a>00427 <span class="comment"> * OCI_ConnectionLogOff</span><a name="l00428"></a>00428 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00429"></a>00429 <a name="l00430"></a>00430 <span class="keywordtype">boolean</span> OCI_ConnectionLogOff(<a class="code" href="struct_o_c_i___connection.html" title="Oracle physical connection.">OCI_Connection</a> *con)<a name="l00431"></a>00431 {<a name="l00432"></a>00432     <span class="keywordtype">boolean</span> res = TRUE;<a name="l00433"></a>00433 <a name="l00434"></a>00434     OCI_CHECK(con == NULL, FALSE);<a name="l00435"></a>00435     OCI_CHECK(con-&gt;<a class="code" href="struct_o_c_i___connection.html#25639578bd259929189e6b842598a187">cstate</a> != OCI_CONN_LOGGED, FALSE);<a name="l00436"></a>00436 <a name="l00437"></a>00437     <span class="comment">/* free all statements */</span><a name="l00438"></a>00438     <a name="l00439"></a>00439     OCI_ListForEach(con-&gt;<a class="code" href="struct_o_c_i___connection.html#624935bfd26cde34ec0a2599e4362264">stmts</a>, (boolean (*)(<span class="keywordtype">void</span> *)) OCI_StatementClose);<a name="l00440"></a>00440     OCI_ListClear(con-&gt;<a class="code" href="struct_o_c_i___connection.html#624935bfd26cde34ec0a2599e4362264">stmts</a>);<a name="l00441"></a>00441 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -