pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ODBCv3 help...
3+ messages / 2 participants
[nested] [flat]

* ODBCv3 help...
@ 2004-07-01 20:04  Eric Olson <ericgolson@gmail.com>
  0 siblings, 2 replies; 3+ messages in thread

From: ericgolson@gmail.com @ 2004-07-01 20:04 UTC (permalink / raw)
  To: pgsql-odbc

my system is configured as follows:
Red Hat 8, postgreSQL 7.4.3, psqlodbc-07.03.0200, and unixODBC-2.2.9.

I have been trying to get the following very simple code snippet
working but it always seg faults after connecting to the db....it
connects then if I try to execute a sql statement it seg faults or in
the below example just freeing the DBC handle will cause a seg
fault...am I missing something?? with the v2 calls to alloc handle and
free handle EVERYTHING works fine...I'm thinking maybe I didn't
configure something properly to use ODBCv3?:

#include "sql.h"
#include "sqlext.h"
#include "stdio.h"
int main () {
 
    SQLHENV env;
    SQLHDBC dbc;    
    SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);

    fprintf (stderr, "Allocated ENV\n");

    SQLAllocHandle( SQL_HANDLE_DBC, env, &dbc );
    fprintf (stderr, "Allocated DBC\n");

    SQLConnect( dbc,
                    (SQLCHAR*) "erictest", SQL_NTS,
                    (SQLCHAR* ) "olsoneg", SQL_NTS,
                    (SQLCHAR*) NULL, SQL_NTS );

    fprintf (stderr, "Connected\n");


     SQLDisconnect( dbc );
     
    SQLFreeHandle (SQL_HANDLE_DBC, dbc);

    SQLFreeHandle (SQL_HANDLE_ENV, env);

}


However if I substitute with the V2 ODBC functions like that follows
then everything works:
#include "sql.h"
#include "sqlext.h"
#include "stdio.h"
int main () {
 
    SQLHENV env;
    SQLHDBC dbc;
    SQLAllocEnv (&env);    

    fprintf (stderr, "Allocated ENV\n");

    SQLAllocConnect (env, &dbc);
    fprintf (stderr, "Allocated DBC\n");

    SQLConnect( dbc,
                    (SQLCHAR*) "erictest", SQL_NTS,
                    (SQLCHAR* ) "olsoneg", SQL_NTS,
                    (SQLCHAR*) NULL, SQL_NTS );

    fprintf (stderr, "Connected\n");

     SQLDisconnect( dbc );
     
     SQLFreeConnect (dbc);
     
     SQLFreeEnv (env);
    
}


Any help on why the V2 calls work but the V3 don't would be GREATLY
appreciated...



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: ODBCv3 help...
@ 2004-07-02 20:32  James Chin <jchin@openlinksw.com>
  parent: Eric Olson <ericgolson@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: James Chin @ 2004-07-02 20:32 UTC (permalink / raw)
  To: pgsql-odbc

Hello Eric,

I can't tell you why it's failing.  It sounds like the value of dbc
after the SQLConnect is a NULL value, which would cause SQLDisconnect
to core.  I'd suggest that you perform some error checking:


    if (SQLConnect( dbc,
                    (SQLCHAR*) "erictest", SQL_NTS,
                    (SQLCHAR* ) "olsoneg", SQL_NTS,
                    (SQLCHAR*) NULL, SQL_NTS ) != SQL_SUCCESS)
     { ... then deal with it ...}

If the return value is not SQL_SUCCESS, you would then use SQLError to
determine what the problem is.

Regards,
James Chin
OpenLink Software Inc.
http://www.openlinksw.com
Product Weblogs:
Virtuoso: http://www.openlinksw.com/weblogs/virtuoso
UDA: http://www.openlinksw.com/weblogs/uda
Universal Data Access & Virtual Database Technology


On 1 Jul 2004 13:04:45 -0700, ericgolson@gmail.com (Eric Olson) wrote:

>my system is configured as follows:
>Red Hat 8, postgreSQL 7.4.3, psqlodbc-07.03.0200, and unixODBC-2.2.9.
>
>I have been trying to get the following very simple code snippet
>working but it always seg faults after connecting to the db....it
>connects then if I try to execute a sql statement it seg faults or in
>the below example just freeing the DBC handle will cause a seg
>fault...am I missing something?? with the v2 calls to alloc handle and
>free handle EVERYTHING works fine...I'm thinking maybe I didn't
>configure something properly to use ODBCv3?:
>
>#include "sql.h"
>#include "sqlext.h"
>#include "stdio.h"
>int main () {
> 
>    SQLHENV env;
>    SQLHDBC dbc;    
>    SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
>
>    fprintf (stderr, "Allocated ENV\n");
>
>    SQLAllocHandle( SQL_HANDLE_DBC, env, &dbc );
>    fprintf (stderr, "Allocated DBC\n");
>
>    SQLConnect( dbc,
>                    (SQLCHAR*) "erictest", SQL_NTS,
>                    (SQLCHAR* ) "olsoneg", SQL_NTS,
>                    (SQLCHAR*) NULL, SQL_NTS );
>
>    fprintf (stderr, "Connected\n");
>
>
>     SQLDisconnect( dbc );
>     
>    SQLFreeHandle (SQL_HANDLE_DBC, dbc);
>
>    SQLFreeHandle (SQL_HANDLE_ENV, env);
>
>}
>
>
>However if I substitute with the V2 ODBC functions like that follows
>then everything works:
>#include "sql.h"
>#include "sqlext.h"
>#include "stdio.h"
>int main () {
> 
>    SQLHENV env;
>    SQLHDBC dbc;
>    SQLAllocEnv (&env);    
>
>    fprintf (stderr, "Allocated ENV\n");
>
>    SQLAllocConnect (env, &dbc);
>    fprintf (stderr, "Allocated DBC\n");
>
>    SQLConnect( dbc,
>                    (SQLCHAR*) "erictest", SQL_NTS,
>                    (SQLCHAR* ) "olsoneg", SQL_NTS,
>                    (SQLCHAR*) NULL, SQL_NTS );
>
>    fprintf (stderr, "Connected\n");
>
>     SQLDisconnect( dbc );
>     
>     SQLFreeConnect (dbc);
>     
>     SQLFreeEnv (env);
>    
>}
>
>
>Any help on why the V2 calls work but the V3 don't would be GREATLY
>appreciated...




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: ODBCv3 help...
@ 2004-07-02 21:18  James Chin <jchin@openlinksw.com>
  parent: Eric Olson <ericgolson@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: James Chin @ 2004-07-02 21:18 UTC (permalink / raw)
  To: pgsql-odbc

Eric,

After sending my last message, I recalled that you do have to set
SQL_ATTR_ODBC_VERSION.  This is done before you allocate a connection
handle.  ODBC 3.x Driver Managers and Drivers check the version of the
ODBC spec for which the application is written for.  You specify this
with the SQLSetEnvAttr ODBC API call.

Modify your app as follows:

 
    SQLHENV env;
    SQLHDBC dbc;    
    SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);

    fprintf (stderr, "Allocated ENV\n");

   /* Add the following.*/
   SQLSetEnvAttr (env, 
                                  SQL_ATTR_ODBC_VERSION, 
                                 (SQLPOINTER) SQL_OV_ODBC3,
                                   SQL_IS_UINTEGER);

    SQLAllocHandle( SQL_HANDLE_DBC, env, &dbc );
    fprintf (stderr, "Allocated DBC\n");


I'd still recommend using SQLError to help determine what the problem
is.

Regards,
James Chin
OpenLink Software Inc.
http://www.openlinksw.com
Product Weblogs:
Virtuoso: http://www.openlinksw.com/weblogs/virtuoso
UDA: http://www.openlinksw.com/weblogs/uda
Universal Data Access & Virtual Database Technology
 On 1 Jul 2004 13:04:45 -0700, ericgolson@gmail.com (Eric Olson)
wrote:

>my system is configured as follows:
>Red Hat 8, postgreSQL 7.4.3, psqlodbc-07.03.0200, and unixODBC-2.2.9.
>
>I have been trying to get the following very simple code snippet
>working but it always seg faults after connecting to the db....it
>connects then if I try to execute a sql statement it seg faults or in
>the below example just freeing the DBC handle will cause a seg
>fault...am I missing something?? with the v2 calls to alloc handle and
>free handle EVERYTHING works fine...I'm thinking maybe I didn't
>configure something properly to use ODBCv3?:
>
>#include "sql.h"
>#include "sqlext.h"
>#include "stdio.h"
>int main () {
> 
>    SQLHENV env;
>    SQLHDBC dbc;    
>    SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
>
>    fprintf (stderr, "Allocated ENV\n");
>
>    SQLAllocHandle( SQL_HANDLE_DBC, env, &dbc );
>    fprintf (stderr, "Allocated DBC\n");
>
>    SQLConnect( dbc,
>                    (SQLCHAR*) "erictest", SQL_NTS,
>                    (SQLCHAR* ) "olsoneg", SQL_NTS,
>                    (SQLCHAR*) NULL, SQL_NTS );
>
>    fprintf (stderr, "Connected\n");
>
>
>     SQLDisconnect( dbc );
>     
>    SQLFreeHandle (SQL_HANDLE_DBC, dbc);
>
>    SQLFreeHandle (SQL_HANDLE_ENV, env);
>
>}
>
>
>However if I substitute with the V2 ODBC functions like that follows
>then everything works:
>#include "sql.h"
>#include "sqlext.h"
>#include "stdio.h"
>int main () {
> 
>    SQLHENV env;
>    SQLHDBC dbc;
>    SQLAllocEnv (&env);    
>
>    fprintf (stderr, "Allocated ENV\n");
>
>    SQLAllocConnect (env, &dbc);
>    fprintf (stderr, "Allocated DBC\n");
>
>    SQLConnect( dbc,
>                    (SQLCHAR*) "erictest", SQL_NTS,
>                    (SQLCHAR* ) "olsoneg", SQL_NTS,
>                    (SQLCHAR*) NULL, SQL_NTS );
>
>    fprintf (stderr, "Connected\n");
>
>     SQLDisconnect( dbc );
>     
>     SQLFreeConnect (dbc);
>     
>     SQLFreeEnv (env);
>    
>}
>
>
>Any help on why the V2 calls work but the V3 don't would be GREATLY
>appreciated...




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-07-02 21:18 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-07-01 20:04 ODBCv3 help... Eric Olson <ericgolson@gmail.com>
2004-07-02 20:32 ` James Chin <jchin@openlinksw.com>
2004-07-02 21:18 ` James Chin <jchin@openlinksw.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox