[unixODBC-support] trouble with mysql driver on mono

James Smith james.smith at aleph-one.com
Wed May 12 12:02:17 BST 2010


Nick,

 

firstly, many thanks for your prompt reply. Your help is really appreciated.

 

I ran this program on Mono on Windows and it works fine:

 

+++

 

using System;

using System.Data.Odbc;

 

namespace test

{

      class Program

      {

            public static void Main(string[] args)

            {

                  Console.WriteLine("Creating connection...");

                  

                  OdbcConnection handle = new OdbcConnection(
"DSN=MySQL;UID=root;PWD=#####" );

 

                  Console.WriteLine("Opening connection...");

 

                  handle.Open();

 

                  Console.WriteLine("Done!");

            }

      }

}

 

+++

 

Of course it doesn't work on Mono on Ubuntu, as expected. The Mono
documentation suggests adding the user and password entries to the
connection string but this doesn't make any difference. I ran it under
strace and compared the results to iSQL. Here are links to both files:

 

http://www.foundationsofwebprogramming.com/php/content.php?user_id=1
<http://www.foundationsofwebprogramming.com/php/content.php?user_id=1&name=s
trace.isql.log> &name=strace.isql.log

http://www.foundationsofwebprogramming.com/php/content.php?user_id=1
<http://www.foundationsofwebprogramming.com/php/content.php?user_id=1&name=s
trace.test.log> &name=strace.test.log

 

One thing I noticed is that the test program doesn't appear to open the
'odbcinst.ini' file whereas iSQL does. Hence no logging in the test case, I
guess. Also, iSQL can write to the socket.

 

+++

 

10:25:23.072104 socket(PF_FILE, SOCK_STREAM, 0) = 3

10:25:23.072239 fcntl(3, F_SETFL, O_RDONLY) = 0

10:25:23.072317 fcntl(3, F_GETFL)       = 0x2 (flags O_RDWR)

10:25:23.072396 connect(3, {sa_family=AF_FILE,
path="/var/run/mysqld/mysqld.sock"}, 110) = 0

10:25:23.072703 setsockopt(3, SOL_SOCKET, SO_RCVTIMEO,
"\2003\341\1\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0

10:25:23.072846 setsockopt(3, SOL_SOCKET, SO_SNDTIMEO,
"\2003\341\1\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0

10:25:23.072937 setsockopt(3, SOL_IP, IP_TOS, [8], 4) = -1 EOPNOTSUPP
(Operation not supported)

10:25:23.073036 setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0

10:25:23.073128 read(3, "?\0\0\0\n5.1.37-1ubuntu5.1\0\232\0\0\0zUuqV"...,
16384) = 67

10:25:23.074394 stat("/usr/share/mysql/charsets/Index.xml",
{st_mode=S_IFREG|0644, st_size=18261, ...}) = 0

10:25:23.075426 open("/usr/share/mysql/charsets/Index.xml", O_RDONLY) = 4

10:25:23.075704 read(4, "<?xml version='1.0' encoding=\"ut"..., 18261) =
18261

10:25:23.076023 close(4)                = 0

10:25:23.079932 geteuid()               = 0

10:25:23.080182 write(3,
"P\0\0\1\215\242\2@\0\0\0@\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 84)
= 84

10:25:23.080434 read(3, "\7\0\0\2\0\0\0\2\0\0\0", 16384) = 11

 

+++

 

.whereas the test program can't:

 

+++

 

[pid  9291] 10:28:30.944067 socket(PF_FILE, SOCK_STREAM, 0) = 3

[pid  9291] 10:28:30.944201 fcntl(3, F_SETFL, O_RDONLY) = 0

[pid  9291] 10:28:30.944285 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)

[pid  9291] 10:28:30.944369 connect(3, {sa_family=AF_FILE,
path="/var/run/mysqld/mysqld.sock"}, 110) = 0

[pid  9291] 10:28:30.944795 setsockopt(3, SOL_SOCKET, SO_RCVTIMEO,
"\2003\341\1\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0

[pid  9291] 10:28:30.944901 setsockopt(3, SOL_SOCKET, SO_SNDTIMEO,
"\2003\341\1\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0

[pid  9291] 10:28:30.945003 setsockopt(3, SOL_IP, IP_TOS, [8], 4) = -1
EOPNOTSUPP (Operation not supported)

[pid  9291] 10:28:30.945100 setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4)
= 0

[pid  9291] 10:28:30.945507 read(3,
"?\0\0\0\n5.1.37-1ubuntu5.1\0\234\0\0\0r3C80"..., 16384) = 67

[pid  9291] 10:28:30.947447 stat("/usr/share/mysql/charsets/Index.xml",
{st_mode=S_IFREG|0644, st_size=18261, ...}) = 0

[pid  9291] 10:28:30.947910 open("/usr/share/mysql/charsets/Index.xml",
O_RDONLY) = 4

[pid  9291] 10:28:30.948364 read(4, "<?xml version='1.0' encoding=\"ut"...,
18261) = 18261

[pid  9291] 10:28:30.948552 close(4)    = 0

[pid  9291] 10:28:30.952986 write(3,
"7\0\0\1\205\242\2@\0\0\0@\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 59)
= 59

[pid  9291] 10:28:30.953245 read(3, "E\0\0\2\377\25\4#28000Access denied for
u"..., 16384) = 73

 

+++

 

Whether this has anything to do with the fact that the test program doesn't
appear to open the 'odbcinst.ini' file at any point I don't know.

 

Kind regards,

 

James

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-support/attachments/20100512/6ca552ca/attachment-0001.html>


More information about the unixODBC-support mailing list