Re: mySQL and SQLDriverConnect

Igor Korot <[email protected]>
Newsgroups gmane.comp.db.unixodbc.devel
Message-ID <16173717.1213852569866.JavaMail.root@elwamui-rubis.atl.sa.earthlink.net>
Hi, Nick,

-----Original Message-----
>From: Nick Gorham <[email protected]>
>Sent: Jun 14, 2008 2:09 AM
>To: Igor Korot <[email protected]>
>Cc: Development issues and topics for unixODBC <[email protected]>
>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>
>Igor Korot wrote:
>
>>Nick,
>>
>>-----Original Message-----
>>  
>>
>>>From: Nick Gorham <[email protected]>
>>>Sent: Jun 13, 2008 5:03 PM
>>>To: Igor Korot <[email protected]>, Development issues and topics for unixODBC <[email protected]>
>>>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
[email protected]
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.