Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Btrieve > Re: Pervasive P...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 6 Topic 911 of 1027
Post > Topic >>

Re: Pervasive PSQL 8.5 and C++ On Linux

by "John C. Frickson" <frickson_AT_gibbon.com> Mar 14, 2007 at 12:28 PM

I tried initializing buflen, and using SQLConnect(). Still get
seg fault.

For grins, I tried installing the 9.5 driver, but it couldn't
talk to the 8.5 server. I didn't think it would work, but it was
worth a try.

Maybe I'll try writing C wrapper functions and call them from
the C++ program.


On 2007-03-13 11:13, Bill Bach wrote:
> Not sure if it is the same thing or not, but this sounds awfully
> similar:
> 	http://bugs.mysql.com/bug.php?id=15248
> 
> Other random suggestions (with no basis whatsoever):
> 1) buflen is not initialized.  Definition I found was "Pointer to the
> total number of bytes (excluding the null termination byte) available
> to return in szConnStrOut."  Not sure if it should be initialized to
> 256 or not.
> 2) Have you tried the more simplistic SQLConnect?  Or do you need more
> flexibility in your "real" code?
> 	BtrieveBill
> 
> John C. Frickson wrote:
> 
>> I'm migrating some of our applications from Windows to our
>> Linux servers. The programs are in C++. They always get a
>> segmentation fault in SQLDriverConnect(). I've created a very
>> simple program in both C and C++ that exhibits the problem.
>> Save as both prg_c.c and prg_cpp.cpp and compiled with:
>>     gcc -m32 -lodbc -o prg_c prg_c.c
>>     g++ -m32 -lodbc -o prg_cpp prg_cpp.c
>> (-m32 because the server is running 64-bit Linux and PSQL
>> only comes with 32-bit drivers.)
>> 
>> -----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
>> #include <string.h>
>> #include <sql.h>
>> #include <sqlext.h>
>> 
>> int main(int argc, char **argv)
>> {
>>    SQLHENV henv;
>>    SQLHDBC hdbc;
>>    SQLCHAR dsn[120];
>>    short buflen;
>>    char buffer[257];
>>    int status;
>> 
>>    strcpy((char*)dsn, "DSN=Paragon");
>>    if (SQLAllocEnv (&henv) != SQL_SUCCESS)
>>      return -1;
>>    if (SQLAllocConnect (henv, &hdbc) != SQL_SUCCESS)
>>      return -1;
>>    status = SQLDriverConnect (hdbc, 0, dsn, SQL_NTS,
>>          (SQLCHAR*)buffer, sizeof (buffer), &buflen,
>>          SQL_DRIVER_COMPLETE);
>>    if (status != SQL_SUCCESS && status != SQL_SUCCESS_WITH_INFO)
>>      return -1;
>>    SQLDisconnect (hdbc);
>>    SQLFreeConnect (hdbc);
>>    SQLFreeEnv (henv);
>> 
>>    return 0;
>> }
>> -----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
>> 
>> The straight C program runs fine. The C++ program blows in
>> the SQLDriverConnect() call.
>> 
>> I've tried both -lodbc and -liodbc and both fail at the same
>> place.
>> 
>> John
>
 




 6 Posts in Topic:
Pervasive PSQL 8.5 and C++ On Linux
"John C. Frickson&qu  2007-03-12 14:40:16 
Re: Pervasive PSQL 8.5 and C++ On Linux
"Bill Bach" <  2007-03-13 11:13:40 
Re: Pervasive PSQL 8.5 and C++ On Linux
"John C. Frickson&qu  2007-03-14 12:28:37 
Re: Pervasive PSQL 8.5 and C++ On Linux
"Bill Bach" <  2007-03-15 07:16:56 
Re: Pervasive PSQL 8.5 and C++ On Linux
"John C. Frickson&qu  2007-03-23 16:20:58 
Re: Pervasive PSQL 8.5 and C++ On Linux
"Bill Bach" <  2007-03-23 17:32:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 13:00:49 CDT 2008.