All Forums |
Register |
Login |
Search |
Subscriptions |
My Profile |
Inbox |
Tool Warehouse |
FAQs |
Resources |
Help |
Member List |
Address Book |
Logout |
|
|
unixODBC-2.2.11 does not work
|
Logged in as: Guest |
Users viewing this topic: none |
|
Login  |
|
|
unixODBC-2.2.11 does not work - Mar. 16, '06, 1:00:58 AM
|
|
|
shailishi
Posts: 15
Joined: Jan. 6, '06,
Status: offline
|
I downloaded the source of unixODBC-2.2.11 form site and was able to build it with some changes. but its not working.
i dont know if i am missing somthing. Please suggest.
also source of unixODBC-2.2.8 is not available on the interop site so i am not able to verify..whats wrong.
Please help me ...
Thanks,
|
|
|
RE: unixODBC-2.2.11 does not work and - Mar. 16, '06, 5:34:18 AM
|
|
|
shailishi
Posts: 15
Joined: Jan. 6, '06,
Status: offline
|
I am getting core dump, while i tried to run this downloaded program. I can see following stack trace..
#0 0x775a5b36 in _alloca () from /usr/local/lib/libiconv.so
#1 0x10070258 in __RUNTIME_PSEUDO_RELOC_LIST__ ()
from /usr/local/unixODBC/lib/libodbc.so.1
#2 0x1004fbb2 in SQLGetPrivateProfileString ()
from /usr/local/unixODBC/lib/libodbc.so.1
#3 0x10001170 in __SQLAllocHandle () from /usr/local/unixODBC/lib/libodbc.so.1
#4 0x10002958 in SQLAllocHandle () from /usr/local/unixODBC/lib/libodbc.so.1
#5 0x004016b8 in new_henv ()
#6 0x00401892 in main ()
Need help . Please suggest if i am doing somthing wrong.
FYI: same thing works fine in unixODBC-2.2.8 available on this site.
#include <stdlib.h>
#include <stdio.h>
#include </usr/local/unixODBC/include/sql.h>
#include </usr/local/unixODBC/include/sqlext.h>
#include <pthread.h>
#include<sys/time.h>
static void odbc_sqlerror(SQLSMALLINT type, SQLHANDLE handle){
SQLCHAR state[7];
SQLCHAR text[1024];
SQLSMALLINT len;
int i=0;
SQLINTEGER native;
while( SQL_SUCCEEDED(SQLGetDiagRec(type, handle, ++i, state, &native,
text, sizeof(text), &len))) {
fprintf(stderr, "(%d) %s:%ld:%s\n", i, state, native, text);
}
}
static SQLHDBC new_hdbc(const char *db, SQLHENV henv){
SQLRETURN retcode;
SQLHDBC hdbc;
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
odbc_sqlerror(SQL_HANDLE_DBC, hdbc);
return NULL;
}
retcode = SQLConnect(hdbc, "testdb", SQL_NTS,
"testuser", 0, "tsetpassword", 0);
if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
odbc_sqlerror(SQL_HANDLE_DBC, hdbc);
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
return NULL;
}
return hdbc;
}
static void free_hdbc(SQLHDBC hdbc){
int retcode;
retcode = SQLDisconnect(hdbc);
if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
odbc_sqlerror(SQL_HANDLE_DBC, hdbc);
}
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
odbc_sqlerror(SQL_HANDLE_DBC, hdbc);
}
}
static SQLHENV new_henv(void){
SQLHENV henv;
SQLRETURN retcode;
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
odbc_sqlerror(SQL_HANDLE_ENV, henv);
return NULL;
}
printf("new_hen:SQLAllocHandle:");
SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3,
0);
printf("new_hen: SQLSetEnvAttr");
return henv;
}
static void free_henv(SQLHDBC henv){
int retcode;
retcode = SQLFreeHandle(SQL_HANDLE_ENV, henv);
if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
odbc_sqlerror(SQL_HANDLE_ENV, henv);
}
}
void *routine(void *arg){
#define NB_CNX 6
SQLHENV henv;
SQLHDBC hdbc[NB_CNX];
int i;
int j;
int release_henv = 0;
henv = (SQLHENV)arg;
if (henv == NULL) {
release_henv = 1;
if ((henv = new_henv()) == NULL) {
return NULL;
}
}
for (i = 0; i < NB_CNX; i++) {
printf("Thread %x: opening connection %d\n", pthread_self(),
i);
if ((hdbc = new_hdbc("DB", henv)) == NULL) {
return NULL;
}
}
for (i = 0; i < NB_CNX; i++) {
printf("Thread %x: closing connection %d\n", pthread_self(),
i);
free_hdbc(hdbc);
}
if (release_henv) {
free_henv(henv);
}
return NULL;
}
int main(){
#define NB_THREAD 10
pthread_t thread[NB_THREAD];
int i;
struct timeval tv;
SQLHENV henv;
/* setting this variable to 1 will force the program to use
only one SQLHENV allocated in the main program. however if set to 0
the program will allocate an SQLHENV in each thread
*/
int one_henv = 1;
if (one_henv) {
if ((henv = new_henv()) == NULL) {
return 0;
}
}
for (i = 0; i < NB_THREAD; i++) {
pthread_create(&thread, NULL, routine, (one_henv) ? henv :
NULL);
}
for (i = 0; i < NB_THREAD; i++) {
pthread_join(thread, NULL);
}
if (one_henv) {
free_henv(henv);
}
}
|
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
|
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts |
|
|
|