
|
mySQL and SQLDriverConnect
Hi, ALL,
It looks like mySQL people don't use SQLDriverConnect at all... ;-)
I'm trying to connect to the mySQL server locally using the ODBC driver from mySQL site
with unixODBC-2.2.12. And I'm using SQLDriverConnect in my C++ program.
When I tried to use isql I get the connection without any problems. I issued:
> isql test root
entered password, and everything is OK.
However, I want to use SQLDriverConnect in my program. So I created a connection
string that was looked like this (tried all those combinations):
DSN=test
DSN=test;UID=root;PWD=<my_password_to_db>
DSN=test;UserID=root;PWD=<my_password_to_db>
DSN=test;UID=root;Password=<my_password_to_db>
DSN=test;UserID=root;Password=<my_password_to_db>
DSN=test;USER=root;Password=<my_password_to_db>
DSN=test;USER=root;PWD=<my_password_to_db>
All of them failed. I guess I'm missing some options that I have to pass, but have no idea
what is it...
Here is a link to the mySQL forum, where I submitted this question:
http://forums.mysql.com/read.php?10,212659,214002#msg-214002.
Thank you for any help you can give.
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Igor Korot wrote:
>Hi, ALL,
>It looks like mySQL people don't use SQLDriverConnect at all... ;-)
>
>I'm trying to connect to the mySQL server locally using the ODBC driver from mySQL site
>with unixODBC-2.2.12. And I'm using SQLDriverConnect in my C++ program.
>
>When I tried to use isql I get the connection without any problems. I issued:
>
>
>
Check that the driver build is using the libodbcinst.so API to access
the ini file, if not it may be doing its own thing and not finding it.
Try setting theenv var ODBCINI to the odbc.ini you are using.
--
Nick
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Nick,
-----Original Message-----
>From: Nick Gorham < nick@...>
>Sent: Jun 13, 2008 5:03 PM
>To: Igor Korot < ikorot@...>, Development issues and topics for unixODBC < unixodbc-dev@...>
>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>
>Igor Korot wrote:
>
>>Hi, ALL,
>>It looks like mySQL people don't use SQLDriverConnect at all... ;-)
>>
>>I'm trying to connect to the mySQL server locally using the ODBC driver from mySQL site
>>with unixODBC-2.2.12. And I'm using SQLDriverConnect in my C++ program.
>>
>>When I tried to use isql I get the connection without any problems. I issued:
>>
>>
>>
>Check that the driver build is using the libodbcinst.so API to access
>the ini file, if not it may be doing its own thing and not finding it.
>Try setting theenv var ODBCINI to the odbc.ini you are using.
2 points:
1. isql works:
isql test root
but it uses SQLConnect to get a connection, so it does not tell us anything,
right?
2. SQLDriverConnect() function is overridden inside the mySQL driver. But it
should call the function from the ODBC API, and then fall down to the driver one,
right?
Thank you.
>
>--
>Nick
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Igor Korot wrote:
>Nick,
>
>-----Original Message-----
>
>
>>From: Nick Gorham < nick@...>
>>Sent: Jun 13, 2008 5:03 PM
>>To: Igor Korot < ikorot@...>, Development issues and topics for unixODBC < unixodbc-dev@...>
>>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>>
>>Igor Korot wrote:
>>
>>
>>
>>>Hi, ALL,
>>>It looks like mySQL people don't use SQLDriverConnect at all... ;-)
>>>
>>>I'm trying to connect to the mySQL server locally using the ODBC driver from mySQL site
>>>with unixODBC-2.2.12. And I'm using SQLDriverConnect in my C++ program.
>>>
>>>When I tried to use isql I get the connection without any problems. I issued:
>>>
>>>
>>>
>>>
>>>
>>Check that the driver build is using the libodbcinst.so API to access
>>the ini file, if not it may be doing its own thing and not finding it.
>>Try setting theenv var ODBCINI to the odbc.ini you are using.
>>
>>
>
>2 points:
>
>1. isql works:
>
>isql test root
>
>but it uses SQLConnect to get a connection, so it does not tell us anything,
>right?
>
>2. SQLDriverConnect() function is overridden inside the mySQL driver. But it
>should call the function from the ODBC API, and then fall down to the driver one,
>right?
>
>
Yes, all the DM does, is look for a DSN= or DRIVER= in the connection
string, and use that toi decide what drive to load, then it loads that
driver and passes the call with the arguments the same onto the driver.
--
Nick
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Hi, Nick,
-----Original Message-----
>From: Nick Gorham < nick@...>
>Sent: Jun 14, 2008 2:09 AM
>To: Igor Korot < ikorot@...>
>Cc: Development issues and topics for unixODBC < unixodbc-dev@...>
>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>
>Igor Korot wrote:
>
>>Nick,
>>
>>-----Original Message-----
>>
>>
>>>From: Nick Gorham < nick@...>
>>>Sent: Jun 13, 2008 5:03 PM
>>>To: Igor Korot < ikorot@...>, Development issues and topics for unixODBC < unixodbc-dev@...>
>>>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>>>
>>>Igor Korot wrote:
>>>
>>>
>>>
>>>>Hi, ALL,
>>>>It looks like mySQL people don't use SQLDriverConnect at all... ;-)
>>>>
>>>>I'm trying to connect to the mySQL server locally using the ODBC driver from mySQL site
>>>>with unixODBC-2.2.12. And I'm using SQLDriverConnect in my C++ program.
>>>>
>>>>When I tried to use isql I get the connection without any problems. I issued:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>Check that the driver build is using the libodbcinst.so API to access
>>>the ini file, if not it may be doing its own thing and not finding it.
>>>Try setting theenv var ODBCINI to the odbc.ini you are using.
>>>
>>>
>>
>>2 points:
>>
>>1. isql works:
>>
>>isql test root
>>
>>but it uses SQLConnect to get a connection, so it does not tell us anything,
>>right?
>>
>>2. SQLDriverConnect() function is overridden inside the mySQL driver. But it
>>should call the function from the ODBC API, and then fall down to the driver one,
>>right?
>>
>>
>Yes, all the DM does, is look for a DSN= or DRIVER= in the connection
>string, and use that toi decide what drive to load, then it loads that
>driver and passes the call with the arguments the same onto the driver.
>
>--
>Nick
I think I found the problem.
I have unixODBC-2.2.12 and myODBC-3.51.12 installed on my Gentoo box.
Here are relevant files:
/etc/unixODBC/odbcinst.ini
[mySQL]
Description = mySQL ODBC driver
Driver = /usr/lib/libmyodbc3.so
Driver64 = /usr/local/lib
Setup = /usr/lib/libodbcmyS.so
Setup64 = /usr/local/lib
UsageCount = 1
CPTimeout =
CPReuse =
/etc/unixODBC/odbc.ini - empty file
/home/igor/.odbc.ini
[test]
Description = mySQL test
Driver = mySQL
Server = localhost
Database = test
Port =
Socket =
Option =
Stmt =
USER = root
Password = <my_password>
Those are 2 calls I tried:
1.
retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"DSN=test;", (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen, SQL_DRIVER_NOPROMPT );
2.
retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;User=root;Password=wasqra;Option=3;", (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen, SQL_DRIVER_NOPROMPT );
Both calls fails, returning -1 in the "retcode".
Again connecting using isql works, which means that the driver works and it's something wrong with the SQLDriverConnect logic.
Maybe in the first case it's looking for the global (system) DSN only, and does not fallback to the user one?
And for the second case I don't even know.
Can you or someone else confirm?
Thank you.
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Igor Korot wrote:
>Hi, Nick,
>
>
>1.
>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"DSN=test;", (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen, SQL_DRIVER_NOPROMPT );
>
>2.
>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;User=root;Password=wasqra;Option=3;", (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen, SQL_DRIVER_NOPROMPT );
>
>Both calls fails, returning -1 in the "retcode".
>
>Again connecting using isql works, which means that the driver works and it's something wrong with the SQLDriverConnect logic.
>Maybe in the first case it's looking for the global (system) DSN only, and does not fallback to the user one?
>And for the second case I don't even know.
>
>Can you or someone else confirm?
>
>Thank you.
>
>
What error is returned from SQLDriverConnect, I think it might be worth
asking the question of the driver writers, as I think thats where the
problem might lie.
--
Nick
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Hi,
-----Original Message-----
>From: Nick Gorham < nick@...>
>Sent: Jun 18, 2008 11:40 PM
>To: Igor Korot < ikorot@...>
>Cc: Development issues and topics for unixODBC < unixodbc-dev@...>
>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>
>Igor Korot wrote:
>
>>Hi, Nick,
>>
>>
>>1.
>>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"DSN=test;", (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen, SQL_DRIVER_NOPROMPT );
>>
>>2.
>>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;User=root;Password=wasqra;Option=3;", (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen, SQL_DRIVER_NOPROMPT );
>>
>>Both calls fails, returning -1 in the "retcode".
>>
>>Again connecting using isql works, which means that the driver works and it's something wrong with the SQLDriverConnect logic.
>>Maybe in the first case it's looking for the global (system) DSN only, and does not fallback to the user one?
>>And for the second case I don't even know.
>>
>>Can you or someone else confirm?
>>
>>Thank you.
>>
>>
>What error is returned from SQLDriverConnect, I think it might be worth
>asking the question of the driver writers, as I think thats where the
>problem might lie.
Before I go ask this on mySQL site, I want to confirm one thing:
My application compiled with the UNICODE support on.
But I explicitly call non-UNICODE ODBC API function, and the driver I installed is not UNICODE aware.
What's going to happen in this case? Will the app call non-UNICODE function from DM? And if not, how DM
and the driver will communicate?
Thank you.
>
>--
>Nick
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Igor Korot wrote:
>Hi,
>
>-----Original Message-----
>
>
>>From: Nick Gorham < nick@...>
>>Sent: Jun 18, 2008 11:40 PM
>>To: Igor Korot < ikorot@...>
>>Cc: Development issues and topics for unixODBC < unixodbc-dev@...>
>>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>>
>>Igor Korot wrote:
>>
>>
>>
>>>Hi, Nick,
>>>
>>>
>>>1.
>>>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"DSN=test;", (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen, SQL_DRIVER_NOPROMPT );
>>>
>>>2.
>>>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;User=root;Password=wasqra;Option=3;", (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen, SQL_DRIVER_NOPROMPT );
>>>
>>>Both calls fails, returning -1 in the "retcode".
>>>
>>>Again connecting using isql works, which means that the driver works and it's something wrong with the SQLDriverConnect logic.
>>>Maybe in the first case it's looking for the global (system) DSN only, and does not fallback to the user one?
>>>And for the second case I don't even know.
>>>
>>>Can you or someone else confirm?
>>>
>>>Thank you.
>>>
>>>
>>>
>>>
>>What error is returned from SQLDriverConnect, I think it might be worth
>>asking the question of the driver writers, as I think thats where the
>>problem might lie.
>>
>>
>
>Before I go ask this on mySQL site, I want to confirm one thing:
>
>My application compiled with the UNICODE support on.
>But I explicitly call non-UNICODE ODBC API function, and the driver I installed is not UNICODE aware.
>
>What's going to happen in this case? Will the app call non-UNICODE function from DM? And if not, how DM
>and the driver will communicate?
>
>Thank you.
>
>
>
>>--
>>Nick
>>
>>
>
>
>
It should call the non unicode entry point in the driver. You can always
check by adding printf in the driver manager code, thats all I would do
to check.
--
Nick
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Igor Korot wrote:
>Hi,
>
>-----Original Message-----
>
>
>>From: Nick Gorham < nick@...>
>>Sent: Jun 18, 2008 11:40 PM
>>To: Igor Korot < ikorot@...>
>>Cc: Development issues and topics for unixODBC < unixodbc-dev@...>
>>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>>
>>Igor Korot wrote:
>>
>>
>>
>>>Hi, Nick,
>>>
>>>
>>>1.
>>>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"DSN=test;", (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen, SQL_DRIVER_NOPROMPT );
>>>
>>>2.
>>>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;User=root;Password=wasqra;Option=3;", (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen, SQL_DRIVER_NOPROMPT );
>>>
>>>Both calls fails, returning -1 in the "retcode".
>>>
>>>Again connecting using isql works, which means that the driver works and it's something wrong with the SQLDriverConnect logic.
>>>Maybe in the first case it's looking for the global (system) DSN only, and does not fallback to the user one?
>>>And for the second case I don't even know.
>>>
>>>Can you or someone else confirm?
>>>
>>>Thank you.
>>>
>>>
>>>
>>>
>>What error is returned from SQLDriverConnect, I think it might be worth
>>asking the question of the driver writers, as I think thats where the
>>problem might lie.
>>
>>
>
>Before I go ask this on mySQL site, I want to confirm one thing:
>
>My application compiled with the UNICODE support on.
>But I explicitly call non-UNICODE ODBC API function, and the driver I installed is not UNICODE aware.
>
>What's going to happen in this case? Will the app call non-UNICODE function from DM? And if not, how DM
>and the driver will communicate?
>
>Thank you.
>
>
By the way, when you say you explicitly call the non unicode function,
do you mean you call SQLDriverConnectA, becaue with UNICODE defined
SQLDriverConnect becomes SQLDreiverConnectW (as it does in windows)
--
Nick
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Nick,
-----Original Message-----
>From: Nick Gorham < nick@...>
>Sent: Jun 20, 2008 12:07 AM
>To: Igor Korot < ikorot@...>
>Cc: Development issues and topics for unixODBC < unixodbc-dev@...>
>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>
>Igor Korot wrote:
>
>>Hi,
>>
>>-----Original Message-----
>>
>>
>>>From: Nick Gorham < nick@...>
>>>Sent: Jun 18, 2008 11:40 PM
>>>To: Igor Korot < ikorot@...>
>>>Cc: Development issues and topics for unixODBC < unixodbc-dev@...>
>>>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>>>
>>>Igor Korot wrote:
>>>
>>>
>>>
>>>>Hi, Nick,
>>>>
>>>>
>>>>1.
>>>>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"DSN=test;", (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen, SQL_DRIVER_NOPROMPT );
>>>>
>>>>2.
>>>>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;User=root;Password=wasqra;Option=3;", (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen, SQL_DRIVER_NOPROMPT );
>>>>
>>>>Both calls fails, returning -1 in the "retcode".
>>>>
>>>>Again connecting using isql works, which means that the driver works and it's something wrong with the SQLDriverConnect logic.
>>>>Maybe in the first case it's looking for the global (system) DSN only, and does not fallback to the user one?
>>>>And for the second case I don't even know.
>>>>
>>>>Can you or someone else confirm?
>>>>
>>>>Thank you.
>>>>
>>>>
>>>>
>>>>
>>>What error is returned from SQLDriverConnect, I think it might be worth
>>>asking the question of the driver writers, as I think thats where the
>>>problem might lie.
>>>
>>>
>>
>>Before I go ask this on mySQL site, I want to confirm one thing:
>>
>>My application compiled with the UNICODE support on.
>>But I explicitly call non-UNICODE ODBC API function, and the driver I installed is not UNICODE aware.
>>
>>What's going to happen in this case? Will the app call non-UNICODE function from DM? And if not, how DM
>>and the driver will communicate?
>>
>>Thank you.
>>
>>
>By the way, when you say you explicitly call the non unicode function,
>do you mean you call SQLDriverConnectA, becaue with UNICODE defined
>SQLDriverConnect becomes SQLDreiverConnectW (as it does in windows)
retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"DSN=test;", ...);
^^^^^^^^^^^^^^
I am doing casting of the parameters.
In UNICODE version, this would become (SQLWCHAR FAR *).
So, unless the linker is not smart, he should look at the proper signature of the
function.
Or maybe I'm dumb?
Thank you.
>
>--
>Nick
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Igor Korot wrote:
>>>
>>>
>>By the way, when you say you explicitly call the non unicode function,
>>do you mean you call SQLDriverConnectA, becaue with UNICODE defined
>>SQLDriverConnect becomes SQLDreiverConnectW (as it does in windows)
>>
>>
>
>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"DSN=test;", ...);
> ^^^^^^^^^^^^^^
>
>I am doing casting of the parameters.
>In UNICODE version, this would become (SQLWCHAR FAR *).
>
>So, unless the linker is not smart, he should look at the proper signature of the
>function.
>
>
>
Not entirly correct
(SQLTCHAR FAR *)"DSN=test;"
when UNICODE is defined, will create a SQLWCHAR * pointer, but the thing it points to will still be a char string;
I think thats the problem, you are passing the address 8bit string into a function thats expecting a 16bit sequence of values. Casting the pointer to a pointer of another type will not alter the thing thats being pointed to.
Remember C will do what you tell it to, even if thats not what you want it to do :-)
--
Nick
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Nick,
-----Original Message-----
>From: Nick Gorham < nick@...>
>Sent: Jun 20, 2008 8:36 AM
>To: Igor Korot < ikorot@...>
>Cc: Development issues and topics for unixODBC < unixodbc-dev@...>
>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>
>Igor Korot wrote:
>
>>>>
>>>>
>>>By the way, when you say you explicitly call the non unicode function,
>>>do you mean you call SQLDriverConnectA, becaue with UNICODE defined
>>>SQLDriverConnect becomes SQLDreiverConnectW (as it does in windows)
>>>
>>>
>>
>>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"DSN=test;", ...);
>> ^^^^^^^^^^^^^^
>>
>>I am doing casting of the parameters.
>>In UNICODE version, this would become (SQLWCHAR FAR *).
>>
>>So, unless the linker is not smart, he should look at the proper signature of the
>>function.
>>
>>
>>
>Not entirly correct
>
>(SQLTCHAR FAR *)"DSN=test;"
>
>when UNICODE is defined, will create a SQLWCHAR * pointer, but the thing it points to will still be a char string;
>
>I think thats the problem, you are passing the address 8bit string into a function thats expecting a 16bit sequence of values. Casting the pointer to a pointer of another type will not alter the thing thats being pointed to.
>
>Remember C will do what you tell it to, even if thats not what you want it to do :-)
Ok, it is very easy to check. ;-)
It is morning here and I'm at work. When I come home, I will enable ODBC logging and run my
program. Hopefully you are right, I was just banging my head over nothing and simply passing:
"DSN=test;" without casting should fix the issue.
Thank you.
P.S.: Sometimes it's good to do RTFM ;-)
>
>--
>Nick
>
>
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Igor Korot wrote:
>Nick,
>
>-----Original Message-----
>
>
>>From: Nick Gorham < nick@...>
>>Sent: Jun 20, 2008 8:36 AM
>>To: Igor Korot < ikorot@...>
>>Cc: Development issues and topics for unixODBC < unixodbc-dev@...>
>>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>>
>>Igor Korot wrote:
>>
>>
>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>By the way, when you say you explicitly call the non unicode function,
>>>>do you mean you call SQLDriverConnectA, becaue with UNICODE defined
>>>>SQLDriverConnect becomes SQLDreiverConnectW (as it does in windows)
>>>>
>>>>
>>>>
>>>>
>>>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"DSN=test;", ...);
>>> ^^^^^^^^^^^^^^
>>>
>>>I am doing casting of the parameters.
>>>In UNICODE version, this would become (SQLWCHAR FAR *).
>>>
>>>So, unless the linker is not smart, he should look at the proper signature of the
>>>function.
>>>
>>>
>>>
>>>
>>>
>>Not entirly correct
>>
>>(SQLTCHAR FAR *)"DSN=test;"
>>
>>when UNICODE is defined, will create a SQLWCHAR * pointer, but the thing it points to will still be a char string;
>>
>>I think thats the problem, you are passing the address 8bit string into a function thats expecting a 16bit sequence of values. Casting the pointer to a pointer of another type will not alter the thing thats being pointed to.
>>
>>Remember C will do what you tell it to, even if thats not what you want it to do :-)
>>
>>
>
>Ok, it is very easy to check. ;-)
>It is morning here and I'm at work. When I come home, I will enable ODBC logging and run my
>program. Hopefully you are right, I was just banging my head over nothing and simply passing:
>"DSN=test;" without casting should fix the issue.
>
>
No, that sill wont work, you either need to pass a wide string, or
force the use of the ansi function
SQLWCHAR str[] = { 'D','S','N','='.''t','e','s','t',';',0 };
SQLDriverConnect( ... str, SQL_NTS, ... );
or
SQLCHAR *str = "dsn=test;";
SQLDriverConnectA( ..., str, SQL_NTS, ... );
--
Nick Gorham
Easysoft Limited
http://www.easysoft.com, http://www.unixODBC.org_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
Nick,
-----Original Message-----
>From: Nick Gorham < nick.gorham@...>
>Sent: Jun 20, 2008 12:16 PM
>To: Igor Korot < ikorot@...>, Development issues and topics for unixODBC < unixodbc-dev@...>
>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>
>Igor Korot wrote:
>
>>Nick,
>>
>>-----Original Message-----
>>
>>
>>>From: Nick Gorham < nick@...>
>>>Sent: Jun 20, 2008 8:36 AM
>>>To: Igor Korot < ikorot@...>
>>>Cc: Development issues and topics for unixODBC < unixodbc-dev@...>
>>>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>>>
>>>Igor Korot wrote:
>>>
>>>
>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>By the way, when you say you explicitly call the non unicode function,
>>>>>do you mean you call SQLDriverConnectA, becaue with UNICODE defined
>>>>>SQLDriverConnect becomes SQLDreiverConnectW (as it does in windows)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"DSN=test;", ...);
>>>> ^^^^^^^^^^^^^^
>>>>
>>>>I am doing casting of the parameters.
>>>>In UNICODE version, this would become (SQLWCHAR FAR *).
>>>>
>>>>So, unless the linker is not smart, he should look at the proper signature of the
>>>>function.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>Not entirly correct
>>>
>>>(SQLTCHAR FAR *)"DSN=test;"
>>>
>>>when UNICODE is defined, will create a SQLWCHAR * pointer, but the thing it points to will still be a char string;
>>>
>>>I think thats the problem, you are passing the address 8bit string into a function thats expecting a 16bit sequence of values. Casting the pointer to a pointer of another type will not alter the thing thats being pointed to.
>>>
>>>Remember C will do what you tell it to, even if thats not what you want it to do :-)
>>>
>>>
>>
>>Ok, it is very easy to check. ;-)
>>It is morning here and I'm at work. When I come home, I will enable ODBC logging and run my
>>program. Hopefully you are right, I was just banging my head over nothing and simply passing:
>>"DSN=test;" without casting should fix the issue.
>>
>>
>
>No, that sill wont work, you either need to pass a wide string, or
>force the use of the ansi function
>
>SQLWCHAR str[] = { 'D','S','N','='.''t','e','s','t',';',0 };
>SQLDriverConnect( ... str, SQL_NTS, ... );
>
>or
>
>SQLCHAR *str = "dsn=test;";
>SQLDriverConnectA( ..., str, SQL_NTS, ... );
>
>--
>Nick Gorham
>Easysoft Limited
> http://www.easysoft.com, http://www.unixODBC.org>
I turned the logging on and here is the output and my code:
[code]
wchar_t *temp_in = new wchar_t[connectStr.length()+1];
RETCODE retcode;
if( FwdOnlyCursors() )
{
retcode = SQLSetConnectOption( m_hdbc, SQL_ODBC_CURSORS, SQL_CUR_USE_IF_NEEDED );
if( retcode != SQL_SUCCESS )
wxLogError( _T( "SQLSetConnectionOption(CURSOR_LIB) failed!!" ) );
}
SQLTCHAR outConnectStr[SQL_MAX_CONNECTSTR_LEN+1];
short outConnectStrLen;
wxStrcpy( (char *) temp_in, connectStr );
temp_in[connectStr.length()] = '\0';
retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)temp_in, (SWORD) connectStr.length(), (SQLTCHAR FAR *) outConnectStr, WXSIZEOF( outConnectStr ), &outConnectStrLen,
#ifdef __WXMSW__
SQL_DRIVER_PROMPT );
#endif
#ifdef __WXGTK__
SQL_DRIVER_NOPROMPT );
#endif
[/code]
where
connectStr = _T("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;User=root;Password=wasqra;Option=3;" )
and the log:
[code]
[ODBC][6916][__handles.c][447]
Exit:[SQL_SUCCESS]
Environment = 0x81c7408
[ODBC][6916][SQLSetEnvAttr.c][182]
Entry:
Environment = 0x81c7408
Attribute = SQL_ATTR_ODBC_VERSION
Value = 0x3
StrLen = 0
[ODBC][6916][SQLSetEnvAttr.c][349]
Exit:[SQL_SUCCESS]
[ODBC][6916][SQLAllocHandle.c][358]
Entry:
Handle Type = 2
Input Handle = 0x81c7408
[ODBC][6916][SQLAllocHandle.c][476]
Exit:[SQL_SUCCESS]
Output Handle = 0x81c7998
[ODBC][6916][SQLSetConnectOptionW.c][160]
Entry:
Connection = 0x81c7998
Option = SQL_ATTR_ODBC_CURSORS
Value = 0
[ODBC][6916][SQLDriverConnectW.c][246]
Entry:
Connection = 0x81c7998
Window Hdl = 0x8192180
Str In = [Die=MSLOB .1Die}Sre=oahs;aaaets;srro;asodwsr;pin3][length = 98]
Str Out = 0xbfac0bb0
Str Out Max = 1025
Str Out Ptr = 0xbfac1bb6
Completion = 0
[ODBC][6916][SQLDriverConnectW.c][433]Error: IM002
[/code]
So, it looks like the connection string is passed as a UNICODE in the UNICODE DM function.
Thank you for the hint. Now I know what I need to look for...
Thank you.
_______________________________________________
unixODBC-dev mailing list
unixODBC-dev@...
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
|

|
Re: mySQL and SQLDriverConnect
|