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

📄 connect.c

📁 本源代码是通过oci连接oracle数据库的代码。适合初步接触Oracle的开发者。
💻 C
字号:
/* Copyright (c) 2004, 2005, Oracle. All rights reserved.  *//*   NAME     connect.c - <one-line expansion of the name>   DESCRIPTION     <short description of facility this file declares/defines>   EXPORT FUNCTION(S)     <external functions defined for use outside package - one-line descriptions>   INTERNAL FUNCTION(S)     <other external functions defined - one-line descriptions>   STATIC FUNCTION(S)     <static functions defined - one-line descriptions>   NOTES     <other useful comments, qualifications, etc.>   MODIFIED   (MM/DD/YY)   ardesai     03/04/05 - Include windows.h for windows platform.   subanerj    06/06/04 - subanerj_odbc_env_setup   ardesai     06/02/04 - Creation*/#ifdef WIN32COMMON#include <windows.h>#endif#include <stdio.h>#include <sql.h>#include <sqlext.h>  #define STR_LEN 50  int main(int argc, char *argv[]){   HENV     henv;                            /* environment handle */  HDBC     hdbc;                            /* connection handle */  HSTMT    hstmt;                           /* statement handle */  SDWORD   retcode;                         /* return code */  UCHAR    info[STR_LEN];                   /* info string for SQLGetInfo */  SQLSMALLINT cbInfoValue;  SQLCHAR SqlState[6], Msg[SQL_MAX_MESSAGE_LENGTH];  SQLINTEGER NativeError;  SQLSMALLINT MsgLen;                    retcode = SQLAllocEnv(&henv);  printf("retcode=%d\n",retcode);  retcode = SQLAllocConnect(henv, &hdbc);  printf("retcode=%d\n",retcode);  //retcode = SQLConnect(hdbc, "TestDBDSN", SQL_NTS, "scott", SQL_NTS, "tiger",  retcode = SQLConnect(hdbc, "dbroker", SQL_NTS, "user1", SQL_NTS, "pwd1",                       SQL_NTS);    printf("retcode=%d\n",retcode);  if (retcode != SQL_SUCCESS)  {    if((retcode = SQLGetDiagRec(SQL_HANDLE_DBC, hdbc, 1, SqlState, &NativeError,                    Msg, sizeof(Msg), &MsgLen)) != SQL_NO_DATA)      printf("SqlState = %s\n Message = %s\n", SqlState, Msg);    goto EXIT;  }         retcode = SQLGetInfo(hdbc,SQL_DBMS_VER, &info, STR_LEN,&cbInfoValue);  printf("Current DBMS version is %s\n", info);    EXIT:      SQLDisconnect(hdbc);      SQLFreeConnect(hdbc);      SQLFreeEnv(henv);  return 0;}/* end of file connect.c */

⌨️ 快捷键说明

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