It doesn't matter whether new data is being written to the db or 
existing data is being read from it. Either way, activerecord generates 
the aforementioned "Mysql::Error: query: not connected" exception.

As described in the first post, the table for this simple illustrative 
example is named 'a' and has one field/column named 'x'.

As also mentioned in the first post, if I call establish_connection with 
an invalid username, password, or database name, the invalidity is 
caught, as expected.

If however all of these are correct, no error occurs from attempting to 
establish the connection. Instead, the aforementioned "Mysql::Error: 
query: not connected" exception is generated when activerecord tries to 
execute the SQL query associated with the operation being performed 
(read or write - as I said, doesn't matter which).

I've confirmed from debugging now that the connection is being made on 
line 585 of activerecord's file mysql_adapter.rb (call to 
@connection.real_connect - not actually hit until my statement above, 
'user = User.new("x" => 5)', is performed).

Unfortunately, it's not possible to step into the above call to 
real_connect to see why no connection actually occurs - presumably 
because it's in a binary library (libmysql.dll). But the parameters 
passed in are as expected.
-- 
Posted via http://www.ruby-forum.com/.