Got Sybase*? Got Rails? You're skewered. But you can do it with JRuby and jTDS. Assuming Ubuntu 9.04, but any deb-based system should do.
*(or MSSQL, or SQLServer, whatever the heck it's called)
Get jruby1.1 (or whatever the latest is). This also might drag in 90+ other
dependencies. You don't have a choice. Get libjtds-java. Get the following gems:
activerecord-jdbc-adapter jruby-openssl
sudo apt-get install jruby1.1 libjtds-java
sudo jruby -S gem install rails activerecord-jdbc-adapter jruby-openssl
jruby -S: installs the gems into the jruby system instead of the ruby (or cruby, for
C) system.
Start a jrails (my term for JRuby on Rails) app by doing:
jruby -S rails jdbctestapp
Edit config/database.yml to read something like:
development:
adapter: jdbc
url: jdbc:jtds:sybase://server:4100/;TDS=5.0
database: mydatabasename
username: foo
password: bar
driver: net.sourceforge.jtds.jdbc.Driver
Assuming you know how to handle the database.yml file. For MSSQL, change 'sybase' to 'sqlserver' and
set TDS=8.0 (or remove the TDS thing altogether, including the semi-colon).
And then, the best-kept secret of the internet: Add this line, or similar, to your environment.rb file:
require '/usr/share/java/jtds.jar'
That's right, the full path to the jtds jar file (you can find it with dpkg -L libjtds-java|grep jar).
Tag: rails
- Sat Oct 10 20:21:19 2009 Gresh wrote:
I've tried using JRuby/Rails with Sybase jConnect and jTds, however it seems migrations are not supported. Initially I get this error:
ActiveRecord::ActiveRecordError: 600 is the maximum allowable size of an index. Composite index specified is 2048 bytes.
: CREATE UNIQUE INDEX [rn_a_unique_schema_migrations] ON rn_a_schema_migrations ([version])
And there then seems to be problems with sequences:
ActiveRecord::ActiveRecordError: Incorrect syntax near the keyword 'IDENTITY'.
: CREATE TABLE rn_a_users ([id] int NOT NULL IDENTITY(1, 1) PRIMARY KEY, [username] varchar(2048), [first_name] varchar(2048), [last_name] varchar(2048), [active] bit, [password] varchar(2048), [salt] varchar(2048), [email] varchar(2048), [created_at] datetime, [updated_at] datetime)
I will try creating the schema I need manually, hopefully rails will work against it.
Also on ASIQ it seems we cannot pick up the list of tables, so even with an existing schema, things fail. I haven't tried yet with jTds.
- Sat Oct 10 23:29:39 2009 Satya wrote:
I don't know jack about the sybase stuff. I just need it to work with what we have at work. I wish Rails supported Sybase better. Supposedly there is an activerecord-sybase-adapter which is not gem-installable. I have not found it.