Archive for the ‘databases’ Category

Fix for Windows + Rails 2.2 + Mysql 5.1 = error

Friday, September 25th, 2009

If you get this error : Mysql::Error: query: not connected: or one just like it, it’s because you need an older DLL.. Which I just happen to have found, because I needed to fix this problem too!
libmySQL.dll

Enjoy.

Connecting to Sybase with Rails on Windows XP

Friday, September 11th, 2009

This is known to work on ASE 12.5.1 – you’re welcome to let me know what else worked, I am particularly curious about later versions of Sybase ASE, such as 15.

Prerequisites:

  1. Sybase PC Client 12.52
  2. The Ruby Sybase  files
  3. gem install activerecord-sybase-adapter -s http://gems.rubyonrails.org

Put the Sybase files in C:\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt .

Copy all the DLLs in %SYBASE%\OCS-12_5\dll and put them in %RUBY%\bin (if you are not familiar with Windows notation, this simply means to go where you installed each of Sybase and Ruby and then go to the proper subdirectory). Why all of them? Well, because I’m too lazy to know which ones we -do- need.

Set some environment variables, just to make sure Sybase works fine:

Right-click on My Computer, Properties > Advanced > Environment Variables
If you have full permissions, go ahead and add those as SYSTEM VARIABLES.. Otherwise, well, only for your user (but aren’t you doing this on a server?).

SYBASE=c:\sybase    (where you installed Sybase).

JDBC_HOME=c:\sybase\jConnect-6_0   (again, where you installed Sybase, then the subdirectory).

CLASSPATH=%JDBC_HOME%\classes\jconn3.jar (just make sure that’s the right number).

If you’re going to create a user on your Sybase server for specific Rails usage, it needs to have SELECT permissions on the following : sysobjects, syscolumns, systypes, syscomments.

Edit your %SYBASE%\ini\sql.ini and add the information for your server in there.

Next.. In Rails, the magic will look like this in database.yml :

production:
adapter: sybase
database: <YOUR_DB_HERE>
username: <USERNAME>
password: <PASSWORD>
host: <NAME_GIVEN_IN_SQL_INI_HERE>

And that should be pretty much it!

Don’t forget to edit your model if you’re working with legacy data:

class Patient < ActiveRecord::Base
set_table_name "some_odd_name"
set_primary_key "some_primary_key_column"
end

Ruby on Rails + Sybase

Friday, July 31st, 2009

Caveat: This adapter may only work with the enterprise edition of Sybase (i.e. Sybase ASE) not with SQLAnywhere (Sybase ASA)

gem install activerecord-sybase-adapter -s http://gems.rubyonrails.org

ActiveRecord::Base.establish_connection(
:adapter => “sybase”,
:database => “test”,
:host => “www.yourdbserver.com”,
:username => “kevin”,
:password => “test”)

Play!

Passwords, passwords

Tuesday, June 9th, 2009

Default passwords for MSSQL, Sybase, and mySQL:
, , ,
That’s right.. All three have blank root / sa passwords by default. Talk about secure! That’s the kind of knowledge that can come in handy.