[unixODBC-support] What is the Nature of Data Source Names under unixODBC?

Nick Gorham nick at lurcher.org
Fri May 8 20:05:40 BST 2009


Ken Resander wrote:
> About 4-5 years ago I worked on an Intelli-sense type interactive 
> input system
> for databases DB2, Mimer, MySQL and SQL Server that ran on Windows. I 
> am now porting this, all other Windows projects and myself to Ubuntu.
>
> Started porting the DB stuff about two weeks ago. Here are the connect 
> calls on Windows, which I assumed would work Ubuntu under unixODBC. 
> Only one did.
>
> // first three parameters: dsn userid password
> connectSrv ( "MySQL_1" , "root" , "" , &sh )
> connectSrv ( "DB2_1" , "db2admin" , "abcd" , &sh )
> connectSrv ( "kenmimer" , "mimer_store" , "abcd" , &sh )
> connectSrv ( "ASA 9.0 Sample" , "" , "" , &sh )
>
>
>
> I could connect to MySQL more or less right away, but spent about a 
> week on DB2 and Mimer SQL. They both came up with SQLConnect error 
> messages 'DB2_1 not a valid database alias name' and 'kenmimer is not 
> a valid database name'. On Windows I had been conditioned to think 
> that a DSN is just an arbitrary shorthand notation for connection 
> attributes passed from the application to the ODBC system via the 
> SQLConnect, so I just could not understand why it did not work. As a 
> last resort, I changed the DB2_1 dsn to SAMPLE, which is the name of 
> the DB2 sample database. It worked. Mimer SQL worked too when I 
> changed the kenmimer dsn to the name of Mimer's sample database.
>
> MySQL_1 is not a name of one of MySQL's sample databases, but it worked. 
>
>
> I have just managed to get SQL Anywhere to connect to its demo 
> database using the following /etc/odbc.ini:
>
> [SQL Anywhere 11 Demo]
> UserID=DBA
> Password=sql
> DatabaseFile=/home/ken/sa11_samples/sqlanywhere/demo.db
> ServerName=demo_ken
> StartLine=/opt/sqlanywhere11/bin32/dbeng11
> Description=SQL Anywhere 11 Sample Database
> Driver=/opt/sqlanywhere11/lib32/libdbodbc11.so
>
> It did not work when I put [sqlanywheredsn] into /etc/odbc.ini and 
> into my SQLConnect call. Received message 'sqlanywhere not a dsn', so 
> again, it seems the dsn has to be a database name.
>
> What are the rules? The DSN can be an arbitrary string in MySQL, but 
> has to be a databasename for the other databases. Is the decision made 
> by unixODBC, the driver or both?
>

Entirely down to the driver. unixODBC works as you are expecting it to.

-- 
Nick


More information about the unixODBC-support mailing list