当前位置: 首页>>代码示例>>C++>>正文


C++ CConnect类代码示例

本文整理汇总了C++中CConnect的典型用法代码示例。如果您正苦于以下问题:C++ CConnect类的具体用法?C++ CConnect怎么用?C++ CConnect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CConnect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

SQLRETURN ODBC::GetDiagField(SQLSMALLINT HandleType, 
				SQLHANDLE Handle,
				SQLSMALLINT RecNumber, 
				SQLSMALLINT DiagIdentifier,
				SQLPOINTER DiagInfo, 
				SQLSMALLINT BufferLength,
				SQLSMALLINT *StringLengthPtr)
{
	SQLRETURN rc;
	DWORD	ErrorMsgLang = 0;
	CConnect* pConnect;
	CStmt* pStmt;
	CDesc* pDesc;
	
	switch (HandleType)
	{
	case SQL_HANDLE_ENV:
		break;
	case SQL_HANDLE_DBC:
		pConnect = (CConnect*)Handle;
		EnterCriticalSection(&pConnect->m_CSObject);
		ErrorMsgLang = pConnect->getErrorMsgLang();
		break;
	case SQL_HANDLE_STMT:
		pStmt = (CStmt *)Handle;
		pConnect = pStmt->getConnectHandle();
		EnterCriticalSection(&pConnect->m_CSObject);
		ErrorMsgLang = pStmt->getErrorMsgLang();
		break;
	case SQL_HANDLE_DESC:
		pDesc = (CDesc *)Handle;
		pConnect = pDesc->getDescConnect();
		EnterCriticalSection(&pConnect->m_CSObject);
		ErrorMsgLang = pDesc->getErrorMsgLang();
		break;
	default:
		return SQL_INVALID_HANDLE;
	}
	__try{
		rc = ((CHandle *)Handle)->GetDiagField(HandleType, Handle, RecNumber, 
					ErrorMsgLang, DiagIdentifier, DiagInfo, BufferLength, StringLengthPtr);
	}
	__finally {
		switch (HandleType)
		{
			case SQL_HANDLE_ENV:
				break;
			case SQL_HANDLE_DBC:
				LeaveCriticalSection(&pConnect->m_CSObject);
				break;
			case SQL_HANDLE_STMT:
				LeaveCriticalSection(&pConnect->m_CSObject);
				break;
			case SQL_HANDLE_DESC:
				LeaveCriticalSection(&pConnect->m_CSObject);
				break;
		}
	}
	return rc;
}
开发者ID:AlexPeng19,项目名称:incubator-trafodion,代码行数:60,代码来源:sqlhandle.cpp

示例2: CConnect

void CClient::onError()
{
    QMessageBox::critical(this, "Error", "Couldn't connect to server: " + m_socket->errorString());
    CConnect *c = new CConnect();
    c->show();
    close();
}
开发者ID:oktal,项目名称:Bombermelee,代码行数:7,代码来源:cclient.cpp

示例3: Disconnect

SQLRETURN ODBC::Disconnect(SQLHDBC ConnectionHandle)
{

	SQLRETURN rc;
	CConnect	*pConnect;

	if (! gDrvrGlobal.gHandle.validateHandle(SQL_HANDLE_DBC, ConnectionHandle))
		return SQL_INVALID_HANDLE;
	
	pConnect = (CConnect *)ConnectionHandle;
	rc = pConnect->Disconnect();
	return rc;
}
开发者ID:AlexPeng19,项目名称:incubator-trafodion,代码行数:13,代码来源:sqlconnect.cpp

示例4: SetConnectAttr

SQLRETURN ODBC::SetConnectAttr(SQLHDBC ConnectionHandle,
           SQLINTEGER Attribute, 
		   SQLPOINTER Value,
           SQLINTEGER StringLength)
{
	SQLRETURN	rc;
	CConnect	*pConnect;

	if (! gDrvrGlobal.gHandle.validateHandle(SQL_HANDLE_DBC, ConnectionHandle))
		return SQL_INVALID_HANDLE;
	pConnect = (CConnect *)ConnectionHandle;
	rc = pConnect->SetConnectAttr(Attribute, Value, StringLength);
	return rc;
}
开发者ID:AlexPeng19,项目名称:incubator-trafodion,代码行数:14,代码来源:sqlconnect.cpp

示例5: GetInfo

SQLRETURN ODBC::GetInfo(SQLHDBC ConnectionHandle,
           SQLUSMALLINT InfoType, 
		   SQLPOINTER InfoValuePtr,
           SQLSMALLINT BufferLength,
		   SQLSMALLINT *StringLengthPtr)
{
	SQLRETURN	rc;
	CConnect	*pConnect;

	if (! gDrvrGlobal.gHandle.validateHandle(SQL_HANDLE_DBC, ConnectionHandle))
		return SQL_INVALID_HANDLE;
	pConnect = (CConnect *)ConnectionHandle;
	rc = pConnect->GetInfo(InfoType, InfoValuePtr, BufferLength, StringLengthPtr);
	return rc;
}
开发者ID:AlexPeng19,项目名称:incubator-trafodion,代码行数:15,代码来源:sqlconnect.cpp

示例6: BrowseConnect

// ODBC Standard
SQLRETURN ODBC::BrowseConnect(SQLHDBC  ConnectionHandle,
    SQLCHAR 		  *InConnectionString,
    SQLSMALLINT        StringLength1,
    SQLCHAR 		  *OutConnectionString,
    SQLSMALLINT        BufferLength,
    SQLSMALLINT       *StringLength2Ptr)
{
	SQLRETURN	rc;
	CConnect	*pConnect;

	if (! gDrvrGlobal.gHandle.validateHandle(SQL_HANDLE_DBC, ConnectionHandle))
		return SQL_INVALID_HANDLE;
	pConnect = (CConnect *)ConnectionHandle;
	rc = pConnect->BrowseConnect(InConnectionString, StringLength1, OutConnectionString,
			BufferLength, StringLength2Ptr);
	return rc;
}
开发者ID:AlexPeng19,项目名称:incubator-trafodion,代码行数:18,代码来源:sqlconnect.cpp

示例7: NativeSql

extern SQLRETURN ODBC::NativeSql(
    SQLHDBC            ConnectionHandle,
    SQLCHAR 		  *InStatementText,
    SQLINTEGER         TextLength1,
    SQLCHAR 		  *OutStatementText,
    SQLINTEGER         BufferLength,
    SQLINTEGER 		  *TextLength2Ptr)
{
	SQLRETURN		rc = SQL_SUCCESS;
	CConnect		*pConnect;
	SQLINTEGER		InStatementTextLen;
	int  OutStatementTextTransLen;
	char errorMsg[MAX_TRANSLATE_ERROR_MSG_LEN];

	short			InStrLen;
	if (! gDrvrGlobal.gHandle.validateHandle(SQL_HANDLE_DBC, ConnectionHandle))
		return SQL_INVALID_HANDLE;
	
	pConnect = (CConnect *)ConnectionHandle;
		
	InStatementTextLen = pConnect->m_ICUConv->FindStrLength((const char *)InStatementText, TextLength1);
	
	if(pConnect->m_ICUConv->isAppUTF16())
		BufferLength = BufferLength*2;
	
	if (OutStatementText != NULL)
	{
 //SQLRETURN ICUConverter::OutArgTranslationHelper(SQLCHAR* arg, int argLen, char * dest, int destLen, int *transLen, char *errorMsg, bool LengthInUChars)
		if(pConnect->m_ICUConv->m_AppUnicodeType == APP_UNICODE_TYPE_UTF16)
			rc = pConnect->m_ICUConv->InputArgToWCharHelper(InStatementText, InStatementTextLen,
							(UChar*)OutStatementText, BufferLength, &OutStatementTextTransLen, errorMsg);
		else
			rc = pConnect->m_ICUConv->InArgTranslationHelper(InStatementText, InStatementTextLen,
							(char *)OutStatementText, BufferLength, &OutStatementTextTransLen, errorMsg);
		
		if(rc != SQL_ERROR)
		{
			if(rc == SQL_SUCCESS_WITH_INFO)
				pConnect->setDiagRec(DRIVER_ERROR, IDS_01_004);
		}
	}
	if (TextLength2Ptr != NULL)
		*TextLength2Ptr = OutStatementTextTransLen;
	return rc;
}
开发者ID:AlexPeng19,项目名称:incubator-trafodion,代码行数:45,代码来源:sqlconnect.cpp

示例8: Connect

SQLRETURN ODBC::Connect(SQLHDBC ConnectionHandle,
           SQLCHAR *ServerName, 
		   SQLSMALLINT NameLength1,
           SQLCHAR *UserName, 
		   SQLSMALLINT NameLength2,
           SQLCHAR *Authentication, 
		   SQLSMALLINT NameLength3)
{
	SQLRETURN	rc;
	CConnect	*pConnect;
	if (! gDrvrGlobal.gHandle.validateHandle(SQL_HANDLE_DBC, ConnectionHandle))
		return SQL_INVALID_HANDLE;

	pConnect = (CConnect *)ConnectionHandle;
	rc = pConnect->Connect(ServerName, NameLength1, UserName, NameLength2, Authentication, NameLength3,
		TRUE);
	return rc;
}
开发者ID:AlexPeng19,项目名称:incubator-trafodion,代码行数:18,代码来源:sqlconnect.cpp

示例9: DriverConnect

SQLRETURN ODBC::DriverConnect(SQLHDBC            ConnectionHandle,
    SQLHWND            WindowHandle,
    SQLCHAR 		  *InConnectionString,
    SQLSMALLINT        StringLength1,
    SQLCHAR           *OutConnectionString,
    SQLSMALLINT        BufferLength,
    SQLSMALLINT 	  *StringLength2Ptr,
    SQLUSMALLINT       DriverCompletion)
{
	
	SQLRETURN	rc;
	CConnect	*pConnect;

	if (! gDrvrGlobal.gHandle.validateHandle(SQL_HANDLE_DBC, ConnectionHandle))
		return SQL_INVALID_HANDLE;
	pConnect = (CConnect *)ConnectionHandle;
	rc = pConnect->DriverConnect(WindowHandle, InConnectionString, StringLength1, OutConnectionString,
			BufferLength, StringLength2Ptr, DriverCompletion);
	return rc;
}
开发者ID:AlexPeng19,项目名称:incubator-trafodion,代码行数:20,代码来源:sqlconnect.cpp

示例10: CConnect

SQLRETURN CEnv::AllocHandle(SQLSMALLINT HandleType,SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
{
	SQLRETURN rc = SQL_SUCCESS;

	CConnect* pConnect = new CConnect(InputHandle);
	if (pConnect != NULL)
	{
		if ((rc = pConnect->initialize()) == SQL_SUCCESS)
			*OutputHandle = pConnect;
		else
		{
			delete pConnect;
			rc = SQL_ERROR;
		}
	}
	else
	{
		setDiagRec(DRIVER_ERROR, IDS_HY_001);
		rc = SQL_ERROR;
	}
	return rc;
}
开发者ID:AlexPeng19,项目名称:incubator-trafodion,代码行数:22,代码来源:cenv.cpp

示例11: ENDTRANSACT

SQLRETURN ENDTRANSACT(SRVR_CALL_CONTEXT *srvrCallContext)
{
	CEE_status	sts;

    struct odbc_SQLSvc_EndTransaction_exc_ exception_ = {0,0,0};
	ERROR_DESC_LIST_def sqlWarning = {0,0};
	
	UDWORD timerTimeout = srvrCallContext->connectionTimeout;
	CConnect *pConnection = (CConnect *)srvrCallContext->sqlHandle;
	
	if (timerTimeout != 0)
		timerTimeout = (timerTimeout < 180)? 180: timerTimeout;

	sts = odbc_SQLDrvr_EndTransaction_pst_(
									srvrCallContext,
									srvrCallContext->dialogueId,
									srvrCallContext->u.completionType,
                                    &exception_,
                                    &sqlWarning);


	if (sts != CEE_SUCCESS)
	{
		if (sts == CEE_INTERNALFAIL)
			pConnection->setDiagRec(DRIVER_ERROR, IDS_EXCEPTION_MSG,0,"SQL SERVER",
				NULL,SQL_ROW_NUMBER_UNKNOWN,SQL_COLUMN_NUMBER_UNKNOWN,2,"Internal Error","ENDTRANSACT");
		else if (sts == TIMEOUT_EXCEPTION)
				pConnection->setDiagRec(DRIVER_ERROR, IDS_S1_T00, 0, FORMAT_ERROR((long)pConnection->m_srvrTCPIPSystem));
		else if (sts == COMM_LINK_FAIL_EXCEPTION)
				pConnection->setDiagRec(DRIVER_ERROR, IDS_08_S01, 0, FORMAT_ERROR((long)pConnection->m_srvrTCPIPSystem));
		else if (sts == TRANSPORT_ERROR)
				pConnection->setDiagRec(DRIVER_ERROR, IDS_08_S02, 0, FORMAT_ERROR((long)pConnection->m_srvrTCPIPSystem));
		else
			pConnection->setDiagRec(DRIVER_ERROR, IDS_S1_000, sts, FORMAT_ERROR((long)pConnection->m_srvrTCPIPSystem), 
				NULL, SQL_ROW_NUMBER_UNKNOWN, SQL_COLUMN_NUMBER_UNKNOWN, 1,"ENDTRANSACT failed");
		return SQL_ERROR;
	}

    odbc_SQLSvc_EndTransaction_ccf_ (srvrCallContext,
                                     &exception_,
                                     &sqlWarning);

	// 
	// cleanup
	//

	if(exception_.exception_nr == odbc_SQLSvc_EndTransaction_SQLError_exn_ &&
	   exception_.u.SQLError.errorList._length > 0 )
  	      delete[] exception_.u.SQLError.errorList._buffer;

	if(sqlWarning._length > 0)
		delete[] sqlWarning._buffer;


	switch (pConnection->getExceptionNr())
	{
		case CEE_SUCCESS:
			return SQL_SUCCESS;
		case odbc_SQLSvc_EndTransaction_SQLInvalidHandle_exn_:
			return SQL_INVALID_HANDLE;
		default:
			return SQL_ERROR;
	}
} // ENDTRANSACT()
开发者ID:RuoYuHP,项目名称:incubator-trafodion,代码行数:64,代码来源:netconnect.cpp

示例12: odbc_SQLSvc_SetConnectionOption_ccf_

// Call Completion function for operation 'odbc_SQLSvc_SetConnectionOption'
extern "C" void odbc_SQLSvc_SetConnectionOption_ccf_ (
	CEE_tag_def cmptag_
  , const struct odbc_SQLSvc_SetConnectionOption_exc_ *exception_
  , const ERROR_DESC_LIST_def *sqlWarning
  )
{
	
	SRVR_CALL_CONTEXT	*srvrCallContext = (SRVR_CALL_CONTEXT *)cmptag_;
	CConnect			*pConnection = (CConnect *)srvrCallContext->sqlHandle;

	pConnection->setExceptionErrors(exception_->exception_nr, exception_->exception_detail);
	switch (exception_->exception_nr)
	{
	case CEE_SUCCESS:
		if (sqlWarning->_length > 0)
			pConnection->setDiagRec(sqlWarning);
		break;
	case odbc_SQLSvc_SetConnectionOption_SQLError_exn_:
		pConnection->setDiagRec(&exception_->u.SQLError);
		break;
	case odbc_SQLSvc_SetConnectionOption_ParamError_exn_:
		pConnection->setDiagRec(SERVER_ERROR, IDS_PROGRAM_ERROR, exception_->exception_nr, 
				exception_->u.ParamError.ParamDesc, NULL, 
				SQL_ROW_NUMBER_UNKNOWN, SQL_COLUMN_NUMBER_UNKNOWN, 1, pConnection->getSrvrIdentity());
		break;
	case odbc_SQLSvc_SetConnectionOption_SQLInvalidHandle_exn_: //This error code is used tempororily
		pConnection->setDiagRec(SERVER_ERROR, IDS_HY_000, 0, " SQL_ATTR_AUTOCOMMIT can not be changed when transaction is in progress");
		break;
	case odbc_SQLSvc_SetConnectionOption_InvalidConnection_exn_:
		pConnection->setDiagRec(SERVER_ERROR, IDS_08_S01);
		break;
	default:
		pConnection->sendCDInfo(exception_->exception_nr);
		pConnection->setDiagRec(exception_->exception_nr, SETCONNECT_PROCNAME,
					pConnection->getSrvrIdentity());
		break;
	}
}
开发者ID:RuoYuHP,项目名称:incubator-trafodion,代码行数:39,代码来源:netconnect.cpp

示例13: TERMINATE_DIALOG

SQLRETURN TERMINATE_DIALOG(SRVR_CALL_CONTEXT *srvrCallContext)
{
	CEE_status	sts;
	long timerTimeout;

	odbc_SQLSvc_TerminateDialogue_exc_ exception_;

	CConnect *pConnection = (CConnect *)srvrCallContext->sqlHandle;
	timerTimeout = srvrCallContext->connectionTimeout > 10 ? srvrCallContext->connectionTimeout : 10;
	
	sts = odbc_SQLSvc_TerminateDialogue_(NULL,
		srvrCallContext,
		srvrCallContext->dialogueId,
		&exception_);

	if (sts != CEE_SUCCESS)
	{
		if (sts == CEE_INTERNALFAIL)
		{
			pConnection->setDiagRec(DRIVER_ERROR, IDS_EXCEPTION_MSG,0,"SQL SERVER",
				NULL,SQL_ROW_NUMBER_UNKNOWN,SQL_COLUMN_NUMBER_UNKNOWN,2,"Internal Error","TERMINATE_DIALOG");
			return SQL_ERROR;
		}
		pConnection->setDiagRec(DRIVER_ERROR, IDS_S1_000, sts, FORMAT_ERROR((long)pConnection->m_srvrTCPIPSystem),
			NULL, SQL_ROW_NUMBER_UNKNOWN, SQL_COLUMN_NUMBER_UNKNOWN, 1, "TERMINATE_DIALOG failed");
		return SQL_SUCCESS_WITH_INFO;
	}

	// Start CCF
	pConnection->setExceptionErrors(exception_.exception_nr, exception_.exception_detail);
	switch (exception_.exception_nr) {
	case CEE_SUCCESS:
		pConnection->resetGetObjRefHdlOutput();
		break;
	case odbc_SQLSvc_TerminateDialogue_SQLError_exn_:
		if (exception_.exception_detail == 25000)
			pConnection->setDiagRec(DRIVER_ERROR, IDS_25_000);
		else
			pConnection->setDiagRec(&exception_.u.SQLError);
		break;
	case odbc_SQLSvc_TerminateDialogue_ParamError_exn_:
		pConnection->setDiagRec(SERVER_ERROR, IDS_PROGRAM_ERROR, exception_.exception_nr, 
							exception_.u.ParamError.ParamDesc);
		break;
	case odbc_SQLSvc_TerminateDialogue_InvalidConnection_exn_:
		pConnection->sendCDInfo(exception_.exception_nr);
		pConnection->setDiagRec(SERVER_ERROR, IDS_08_S01);
		break;
	default:
		pConnection->sendCDInfo(exception_.exception_nr);
		pConnection->setDiagRec(exception_.exception_nr, TERMINATE_DIALOG_PROCNAME,
				pConnection->getSrvrIdentity());
		break;
	}
	if (exception_.exception_detail != 25000)
		CloseIO (pConnection->m_srvrTCPIPSystem);
	// Close CCF

	//
	// cleanup
	//
	if(exception_.exception_nr == odbc_SQLSvc_TerminateDialogue_SQLError_exn_ &&
	   exception_.u.SQLError.errorList._length > 0 )
  	      delete[] exception_.u.SQLError.errorList._buffer;



	switch (pConnection->getExceptionNr())
	{
		case CEE_SUCCESS:
			return SQL_SUCCESS;
		default:
	// if transaction is open return SQL_ERROR
			if (pConnection->getExceptionDetail() == 25000)
				return -25000;
			else
	// Any other errors treat them as if it has been disconnected
				return SQL_SUCCESS_WITH_INFO;
	}

} // TERMINATE_DIALOG()
开发者ID:RuoYuHP,项目名称:incubator-trafodion,代码行数:81,代码来源:netconnect.cpp

示例14: GETOBJREF

SQLRETURN GETOBJREF(SRVR_CALL_CONTEXT *srvrCallContext)
{
	DWORD			dwTimeout = 0;
	DWORD			curTimeout = 0;
	_timeb			time_start;
	_timeb			time_curr;

	SQLRETURN		rc = SQL_SUCCESS;
	CEE_status		sts;
	short			noOfRetries = 0;
	CConnect		*pConnection;
	VERSION_def		version;
	bool			bloop = true;
	int				dwSleep;

	odbcas_ASSvc_GetObjRefHdl_exc_ exception_ = {0,0,0};
	IDL_OBJECT_def		srvrObjRef;
	DIALOGUE_ID_def 	dialogueId = 0;
	SQL_IDENTIFIER_def	dataSource;
    USER_SID_def 		userSid = {0,0};;
    VERSION_LIST_def 	versionList = {0,0};
	long				isoMapping = 0;
	IDL_long			srvrNodeId = -1;
	IDL_long 		    srvrProcessId = -1;
	long long			timestamp = 0;

	IDL_OBJECT_def fwsrvrObjRef;
	char* pTCP;
	char* pIpAddress;
	char* pPortNumber;
	char* pObjectName;
	IDL_OBJECT_def objRef;
	char* pCheckComma;
	char* pCheck;
	char* srvrSegName=NULL;
	int   getObjRefRetryCnt = 0;

	pConnection = (CConnect *)srvrCallContext->sqlHandle;

	dwTimeout = srvrCallContext->u.connectParams.loginTimeout;
	
	if(dwTimeout != 0)
	{
		dwSleep = (dwTimeout / 3) * 1000;
		dwSleep = dwSleep > 5000 ? 5000 : dwSleep;
		dwSleep = dwSleep < 1000 ? 1000 : dwSleep;
	}
	else
		dwSleep = 5000;


	_ftime(&time_start);

TryAgain:

	pConnection->clearError();
		
	sts = odbcas_ASSvc_GetObjRefHdl_(NULL,
								srvrCallContext,
								srvrCallContext->u.connectParams.inContext,
								srvrCallContext->u.connectParams.userDesc,
								CORE_SRVR,
								getObjRefRetryCnt,
								&exception_,
				 				srvrObjRef,
								&dialogueId,
				 				dataSource,
								&userSid,
								&versionList,
								&isoMapping,
								&srvrNodeId,
								&srvrProcessId,
								&timestamp);

	if (sts != CEE_SUCCESS)
	{
		if (sts == CEE_INTERNALFAIL)
			pConnection->setDiagRec(ASSOC_SERVER_ERROR, IDS_EXCEPTION_MSG,0,"ASSOCIATION SERVICE",
				NULL,SQL_ROW_NUMBER_UNKNOWN,SQL_COLUMN_NUMBER_UNKNOWN,2,"Internal Error","GETOBJREF");
		else if (sts == TIMEOUT_EXCEPTION)
			pConnection->setDiagRec(DRIVER_ERROR, IDS_S1_T00, 0, FORMAT_ERROR((long)pConnection->m_asTCPIPSystem));
		else if ((sts == COMM_LINK_FAIL_EXCEPTION) || (sts == TRANSPORT_ERROR))
			pConnection->setDiagRec(ASSOC_SERVER_ERROR, IDS_ASSOC_SRVR_NOT_AVAILABLE,0, FORMAT_ERROR("ASSOCIATION SERVICE",(long)pConnection->m_asTCPIPSystem),
				NULL,SQL_ROW_NUMBER_UNKNOWN,SQL_COLUMN_NUMBER_UNKNOWN,1,"");
		else
			pConnection->setDiagRec(DRIVER_ERROR, IDS_ASSOC_SRVR_NOT_AVAILABLE, sts, FORMAT_ERROR((long)pConnection->m_asTCPIPSystem), 
				NULL, SQL_ROW_NUMBER_UNKNOWN, SQL_COLUMN_NUMBER_UNKNOWN, 1,LAST_ERROR_TO_TEXT());

		if(versionList._buffer != NULL)
			delete versionList._buffer;
		return SQL_ERROR;
	}
	
	/* Starts CCF */
	pConnection->setExceptionErrors(exception_.exception_nr, exception_.exception_detail);

	switch (exception_.exception_nr)
	{
	case CEE_SUCCESS:
		if (srvrObjRef[0] == 0)
//.........这里部分代码省略.........
开发者ID:RuoYuHP,项目名称:incubator-trafodion,代码行数:101,代码来源:netconnect.cpp

示例15: INITIALIZE_DIALOG

SQLRETURN INITIALIZE_DIALOG(SRVR_CALL_CONTEXT *srvrCallContext)
{
	CEE_status							sts;
	CConnect							*pConnection;
	SQLRETURN							rc = SQL_SUCCESS;
	// RAJANI - for password expiry
	CONNECT_FIELD_ITEMS					connectFieldItems;
	bool								bChangePwd = false;

    odbc_SQLSvc_InitializeDialogue_exc_ exception_ = {0,0,0};
    OUT_CONNECTION_CONTEXT_def outContext;

	pConnection = (CConnect *)srvrCallContext->sqlHandle;
	short retry = 0;

	retryInitializeDialogue:

	do
	{
		sts = odbc_SQLSvc_InitializeDialogue_(NULL,
									srvrCallContext,
									srvrCallContext->u.connectParams.userDesc,
									srvrCallContext->u.connectParams.inContext,
									srvrCallContext->dialogueId,
									&exception_,
									&outContext);
		if (sts == CEE_SUCCESS) break;
		Sleep(100);
	}
	while (sts == COMM_LINK_FAIL_EXCEPTION && retry++ < 3);

	if (sts != CEE_SUCCESS)
	{
		if (sts == CEE_INTERNALFAIL)
			pConnection->setDiagRec(DRIVER_ERROR, IDS_EXCEPTION_MSG,0,"SQL SERVER",
				NULL,SQL_ROW_NUMBER_UNKNOWN,SQL_COLUMN_NUMBER_UNKNOWN,2,"Internal Error","INITIALIZE_DIALOG");
		else if (sts == TIMEOUT_EXCEPTION)
			pConnection->setDiagRec(DRIVER_ERROR, IDS_S1_T00, 0, FORMAT_ERROR((long)pConnection->m_srvrTCPIPSystem));
		else if (sts == COMM_LINK_FAIL_EXCEPTION)
			pConnection->setDiagRec(SERVER_ERROR, IDS_08_S01, 0, FORMAT_ERROR((long)pConnection->m_srvrTCPIPSystem));
		else if (sts == TRANSPORT_ERROR)
			pConnection->setDiagRec(SERVER_ERROR, IDS_08_S02, 0, FORMAT_ERROR((long)pConnection->m_srvrTCPIPSystem));
		else
			pConnection->setDiagRec(DRIVER_ERROR, IDS_S1_000, sts, FORMAT_ERROR((long)pConnection->m_srvrTCPIPSystem), 
				NULL, SQL_ROW_NUMBER_UNKNOWN, SQL_COLUMN_NUMBER_UNKNOWN, 1,"INITIALIZE_DIALOG failed");
		return SQL_ERROR;
	}

	// Start CCF
	pConnection->setExceptionErrors(exception_.exception_nr, exception_.exception_detail);
	
	switch ( exception_.exception_nr) 
	{
	case CEE_SUCCESS:
		pConnection->setOutContext(&outContext);
		break;
	case odbc_SQLSvc_InitializeDialogue_SQLError_exn_:
		if (exception_.exception_detail == 4415) // SECMXO_NO_CERTIFICATE
		{
			try{
				if (pConnection->m_SecPwd->switchCertificate()==SQL_SUCCESS) // successfully switched to the new certificate
					pConnection->setRetryEncryption();
				else // there is no certificate to switch to
					pConnection->setDiagRec(&exception_.u.SQLError);
			}
			catch (SecurityException se) {
				rc= se.getErrCode();
				pConnection->setSecurityError(rc, se.getSQLState(), se.getMsg());
			}
		}
		else
			pConnection->setDiagRec(&exception_.u.SQLError);
		break;
	case odbc_SQLSvc_InitializeDialogue_InvalidUser_exn_:
		if (outContext.outContextOptions1 & OUTCONTEXT_OPT1_DOWNLOAD_CERTIFICATE)
		{
			try {
				pConnection->m_SecPwd->switchCertificate(outContext.outContextOptionString, outContext.outContextOptionStringLen);
			} 
			catch (SecurityException se) {
				rc = se.getErrCode();
				pConnection->setSecurityError(rc, se.getSQLState(), se.getMsg());
			}
			if(rc == SQL_SUCCESS)
				pConnection->setRetryEncryption();
		}
		else if (srvrCallContext->u.connectParams.userDesc->userName != NULL && srvrCallContext->u.connectParams.userDesc->password._buffer != NULL)
			pConnection->setDiagRec(&exception_.u.SQLError);
		break;
	case odbc_SQLSvc_InitializeDialogue_ParamError_exn_:
		pConnection->setDiagRec(SQLMX_ERROR, IDS_28_000, exception_.exception_nr,
			(char*)(LPCTSTR)exception_.u.ParamError.ParamDesc, NULL, 
			SQL_ROW_NUMBER_UNKNOWN, SQL_COLUMN_NUMBER_UNKNOWN, 1, INITIALIZE_DIALOG_PROCNAME);
		break;
	case odbc_SQLSvc_InitializeDialogue_InvalidConnection_exn_:
		pConnection->setDiagRec(SERVER_ERROR, IDS_08_004_01);
		break;
	case odbc_SQLSvc_InitializeDialogue_SQLInvalidHandle_exn_:
		break;
	case odbc_SQLSvc_InitializeDialogue_SQLNeedData_exn_:
//.........这里部分代码省略.........
开发者ID:RuoYuHP,项目名称:incubator-trafodion,代码行数:101,代码来源:netconnect.cpp


注:本文中的CConnect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。