|
Pool de Conexion por ODBC Windev 18 |
Débuté par Victor H Pereyra, 28 nov. 2014 19:52 - Aucune réponse |
| |
| | | |
|
| |
Posté le 28 novembre 2014 - 19:52 |
Estimados:
He logrado hacer por medio del ODBC pool de conexiones desde windev 18, obviamente esto puede aplicarse no solo para versiones posteriores como así también para cualquier BD.
Aqui va las lines de codigo final como habilito el pool de conexión y luego proceso varias consulta aleatorias para comprobar el pooling, desde el monitor de proceso de windows
CONSTANT SQL_ATTR_CONNECTION_POOLING = 201 SQL_CP_ONE_PER_DRIVER = 1 SQL_IS_INTEGER = -6 SQL_CP_OFF = 0 SQL_DRIVER_AWARE_POOLING_SUPPORTED = 65572 // 10024 - DIO N CON 65572 SQL_MAX_MESSAGE_LENGTH = 512 SQL_SUCCESS = 0 SQL_SUCCESS_WITH_INFO = 1 SQL_ATTR_ODBC_VERSION = 200 SQL_OV_ODBC3 = 3 SQL_HANDLE_DBC = 2 SQL_HANDLE_ENV = 1 SQL_NTS = -3 SQL_ERROR = -1 SQL_DRIVER_VER = 7 SQL_ODBC_VER = 10
END
tHoracom, tHorafin is Time tHoracom = TimeSys tHorafin = TimeSys nTconsuta is int
nLngHdbc,nLngHenv,nConetado, nDatos,nIntSvrLen is int
sCADENA is string sCADENA="ODBC32.DLL"
sUid is string = "informix" sTrDSN is string = "informix2" sPwd is string = "T000000"
GetModuleHandle is API Description GetModuleHandle..DLLName = sCADENA GetModuleHandle..FunctionName = "SQLSetEnvAttr" GetModuleHandle..ReturnType = apiInt_4 GetModuleHandle..Parameter[1]..Type = apiInt_4 GetModuleHandle..Parameter[2]..Type = apiInt_4 GetModuleHandle..Parameter[3]..Type = apiInt_4 GetModuleHandle..Parameter[4]..Type = apiInt_4
nResultado is int = GetModuleHandle(0, SQL_ATTR_CONNECTION_POOLING, SQL_CP_ONE_PER_DRIVER, SQL_IS_INTEGER)
SQLALLOCENV is API Description SQLALLOCENV..DLLName = sCADENA SQLALLOCENV..FunctionName = "SQLAllocEnv" SQLALLOCENV..ReturnType = apiSystemInt SQLALLOCENV..Parameter[1]..Type = apiInt_4 nResultado = SQLALLOCENV(&nLngHenv)
sconsulta is string
// ME CONECTO ctConexiones is Connection ctConexiones..Source = "informix2" ctConexiones..Provider = hODBC
FOR i = 1 TO 2000000 STEP 100
sconsulta=[ SELECT first 60000 recno as Numero, nropac as NumeroPaciente, codana as Codigo FROM la070 WHERE nropac between %1 AND %2 ]
sconsulta = StringBuild (sconsulta,200000+i,200000+i+100)
ConnectionNum is int = SQLConnect("informix2", "", "", "", "ODBC")
IF ConnectionNum <> 0 THEN // The connection was successful //info("conetado") END TableDeleteAll(TABLE_TABLA)
bEsExec is boolean = SQLExec(sconsulta, "QRY1")
IF SQLFetch("QRY1") = 0 THEN //BuildBrowsingTable(TABLE_TABLA,"QRY1",taFillTable) SQLTable("QRY1", TABLE_TABLA)
END TableDisplay(TABLE_TABLA) SQLClose("QRY1")
nTconsuta ++
SQLDisconnect()
tHorafin = TimeSys nDifhora is int =TimeDifference( tHoracom , tHorafin) IF nDifhora >= 3600 THEN BREAK
END
END
// aqui mido cuantas consultas puedo hacer en un minuto, para luego compararlo con una conexion statandar. Obviamente desde el pool de conexion realiza mayor consulta 1 a 500 veces mas // y el motor sufre mucho menos en procesar.
Info("Total consulta en 1 min.",nTconsuta)
Espero que esto le sirva a alguien.
Saludos Victor Argentina
Víctor H. Pereyra M.P. 2595
Departamento de Informática
Sucursal Nva . Cba .: Hipólito Yrigoyen 384 5000 Córdoba, Capital Tel.: (0351) 426 9200 int :1234
e-mail: vpereyra@sanatorioallende.com www.sanatorioallende.com.ar |
| |
| |
| | | |
|
| | | | |
| | |
|