Stephen Anderson wrote:
> Hello all,
> 
> I want to give my Ruby programs on a Red Hat Linux box the ability to
> run SQL against
> an AIX box running DB2.  The Red Hat box does not have DB2 installed at
> this time.
> The AIX box does not have Ruby installed.  I'm told another application
> is communicating with this database using ODBC on a given port number.
> 
> DBI appears to be the toolkit for this job, and I'm trying to use the
> sqlsh.rb example
> program to test my installation and names.  So far I've had no success.
> 
> "ruby sqlsh.rb 'dbi:Mysql:database=test;host=localhost' sa ''" works
> against a local Mysql database.
> 
> "ruby sqlsh.rb 'dbi:odbc:database=LSDB;host=<hostname>' username
> password"
> returns: "#<DBI::DatabaseError: S1090 (0) [unixODBC][Driver
> Manager]Invalid string or buffer length>"

Syntax of DBD::ODBC

'dbi:odbc:dsn' where dsn is a ODBC DSN (not a DBI DSN!!!!).

There seems to be nothing wrong with DBI, but with either Ruby/ODBC (don't think so) 
or your unixODBC/database configuration.

The ODBC DSN seems to be wrong.

> If I tunnel the ODBC port I was told from my local box to the DB2
> server,
> and run "ruby sqlsh.rb 'dbi:ODBC:database=LSDB;host=localhost' username
> password"I get:
> "#<DBI::DatabaseError: IM002 (0) [unixODBC][Driver Manager]Data source
> name not found, and no default driver specified>".
> 
> Also tunneling: "ruby sqlsh.rb 'dbi:ODBC:LSDB' username password"
> returns "#<DBI::DatabaseError: IM002 (0) [unixODBC][Driver Manager]Data
> source name not found, and no default driver specified>"

Would you at first try to access a local database with ODBC ? Does it work?
Have you installed LSDB as DSN with the unixODBC Driver manager? 
If you've done this, you should be possible to access the underlying database
with 'dbi:ODBC:LSDB'

> Does this look like I'm using bad arguments to sqlsh.rb?  tunneling the
> wrong port on my end?  have ODBC configured wrong?  need to use
> proxyserver.rb?

I guess, proxyserver.rb may not be that performant than a remote ODBC connection.
But it works with every database.

> If I need to use the proxyserver.rb, how do I do so with sqlsh.rb, or in
> my own code?

If you've started proxyserver.rb with the hostname and port on the remote computer
on which the database runs, you can access it with the DBD::Proxy just like any other
database (use this also in sqlsh.rb):

   'dbi:Proxy:hostname=xxxx;port=yyyy;dsn=anyValidDSN'

The dsn= parameter specifies the local (where proxyserver.rb runs) DBI DSN.

> Any help or advice is GREATLY appreciated since I'd really rather not
> have to go back to Java for this project.

better not ;-)


Regards,

  Michael


-- 
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de