ODBC and multi-threading: basics
От | bernardofhoppe@yahoo.com (zzzmito) |
---|---|
Тема | ODBC and multi-threading: basics |
Дата | |
Msg-id | b62328a6.0406291435.25d90ef7@posting.google.com обсуждение исходный текст |
Ответы |
unsubscribe
|
Список | pgsql-odbc |
Hi, could anyone tell me some basics about working with ODBC in a multithreaded application? Next are some of the questions I have, please, help me by answering any or all of them. Your opinion would be best considered, and also any link would be most appreciated. Situation: I am using the ODBC API from Microsoft Visual C++ with Windows NT 4.0. I use a single application with multiple threads that connect all to the same database, but that might query it multiple times (before disconnecting from it) and at different moments and with different SQL querys from the other threads. Of course simultaneity is a must. Questions: 1) is ODBC a thread safe environment? a) with any DB driver? b) what about Access (mdb databases)? I've heard that the Microsoft Jet Access driver version Jet 4.0 or + is thread safe. If that was to be true, how could I use the Jet driver when I use the ODBC API in my application? Is there a way to configure the Datasource to do so? Do you know about any link talking about this? 2) which of these variables should I keep global so that they can be shared among the threads? (remember they all access to the same DB) - henv (environment handle) - hdbc (connection handle, with which I connect to the same ) - hstmt (statement handle) 3) so, continuing question 2), which actions should be made only 1 time (for all the threads), and which should be made each time a thread wants to access the database? - SQLAllocEnv(&henv); - SQLAllocConnect(henv, &hdbc); - SQLSetConnectOption(hdbc, SQL_LOGIN_TIMEOUT, 20); - SQLConnect(hdbc, (UCHAR*)szDataSource, SQL_NTS, (UCHAR*)szLoginName, SQL_NTS, (UCHAR*)szPassword, SQL_NTS); - SQLAllocStmt(hdbc, &hstmt); - SQLPrepare(hstmt, (UCHAR*) szInst, SQL_NTS); - SQLExecute(hstmt); - SQLFreeStmt(hstmt,SQL_DROP); - SQLDisconnect(hdbc); - SQLFreeConnect(hdbc); - SQLFreeEnv(henv); Thanks indeed in advance and best regards.
В списке pgsql-odbc по дате отправления: