# SQLServer on Rails

**URL:** <https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324>\
**Category:** rubyonrails-talk\
**Created:** [January 3, 2010, 7:10pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324 "2010-01-03T19:10:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve14](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@steve14](https://discuss.rubyonrails.org/u/steve14)\
**Post date:** [January 3, 2010, 7:10pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/1 "2010-01-03T19:10:14Z")

</div>

Does any one know how to setup SQLserver with ruby1.9. It was working on an earlier version and now nothing works! I have installed the gems dbi ,dbd-odbc and activerecord-odbc-adapter and can connect in straight Ruby. However, using rails with database.yml nothing works! I hosed everything and reinstalled rails and now, I get Win32/Parite virus on ruby.exe. Any ideas? I'm losing confidence on open source......

---

<div class="post-metadata">

**Author:** ![Leonardo\_Mateo](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@Leonardo\_Mateo](https://discuss.rubyonrails.org/u/Leonardo_Mateo)\
**Post date:** [January 3, 2010, 8:04pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/2 "2010-01-03T20:04:28Z")

</div>

Ha! really? Poor you, go for a paid solution then.

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [January 3, 2010, 10:34pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/3 "2010-01-03T22:34:47Z")

</div>

Leonardo Mateo wrote:

> > Does any one know how to setup SQLserver with ruby1.9. �It was working on an earlier version and now nothing works! �I have installed the gems dbi ,dbd-odbc and activerecord-odbc-adapter and can connect in straight Ruby. �However, using rails with database.yml nothing works! I hosed everything and reinstalled rails and now, I get Win32/Parite virus on ruby.exe. �Any ideas? �I'm losing confidence on open source......
> 
> Ha! really? Poor you, go for a paid solution then.

It looks you need some teaching about manners.

To Steve: Is there any particular reason why do you need ruby1.9. I also had lots of problems with 1.9 on Windows and went back to 1.8.6 where everything works fine.

Don't fix if it aint broken.

by TheR

---

<div class="post-metadata">

**Author:** ![mceranski](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@mceranski](https://discuss.rubyonrails.org/u/mceranski)\
**Post date:** [January 22, 2010, 6:15pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/4 "2010-01-22T18:15:50Z")

</div>

I wrote this tutorial for using Ruby on Rails with SQL Server. It is very easy to follow: [http://www.codecapers.com/post/A-Ruby-on-Rails-Tutorial-for-NET-Developers.aspx](http://www.codecapers.com/post/A-Ruby-on-Rails-Tutorial-for-NET-Developers.aspx)

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [May 10, 2010, 2:52pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/5 "2010-05-10T14:52:24Z")

</div>

mceranski wrote:

> I wrote this tutorial for using Ruby on Rails with SQL Server. It is very easy to follow: [http://www.codecapers.com/post/A-Ruby-on-Rails-Tutorial-for-NET-Developers.aspx](http://www.codecapers.com/post/A-Ruby-on-Rails-Tutorial-for-NET-Developers.aspx)

mceranski, Thanks for the tutorial. It was informative. Unfortunately I wasn't able to get it to work. I'm running on a WinXP machine, using SQL Server 2008 Express. I am using ruby 1.8.7 and rails 2.3.5. My gem list:

actionmailer (2.3.5) actionpack (2.3.5) activerecord (2.3.5) activerecord-sqlserver-adapter (2.3.5) activeresource (2.3.5) activesupport (2.3.5) cgi\_multipart\_eof\_fix (2.5.0) fastthread (1.0.1) gem\_plugin (0.2.3) linecache (0.43) mongrel (1.1.5) mysql (2.7.3) rack (1.0.1) rails (2.3.5) rake (0.8.7) ruby-debug-base (0.10.3) ruby-debug-ide (0.4.5) rubygems-update (1.3.6) sqlite3-ruby (1.2.1)

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [May 10, 2010, 4:49pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/6 "2010-05-10T16:49:56Z")

</div>

It seems my message got cut off. What I wanted to include was the error log from when I accessed [http://localhost:3000/Contacts](http://localhost:3000/Contacts)

Here it is:

/!\ FAILSAFE /!\ Mon May 10 09:32:43 -0700 2010 &nbsp;&nbsp;Status: 500 Internal Server Error &nbsp;&nbsp;S1090 (0) [Microsoft][ODBC Driver Manager] Invalid string or buffer length &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.3.5/lib/active\_record/connection\_adapters/sqlserver\_adapter.rb:765:in `initialize' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.3.5/lib/active_record/connection_adapters/sqlserver_adapter.rb:765:in `connect' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.3.5/lib/active\_record/connection\_adapters/sqlserver\_adapter.rb:765:in `connect' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.3.5/lib/active_record/connection_adapters/sqlserver_adapter.rb:192:in `initialize' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.3.5/lib/active\_record/connection\_adapters/sqlserver\_adapter.rb:28:in `new' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.3.5/lib/active_record/connection_adapters/sqlserver_adapter.rb:28:in `sqlserver\_connection' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/connection\_adapters/abstract/connection\_pool.rb:223:in `send' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new\_connection' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/connection\_adapters/abstract/connection\_pool.rb:245:in `checkout_new_connection' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `checkout' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/connection\_adapters/abstract/connection\_pool.rb:184:in `loop' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `checkout' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/connection\_adapters/abstract/connection\_pool.rb:98:in `connection' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve\_connection' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/connection\_adapters/abstract/connection\_specification.rb:123:in `retrieve_connection' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `connection' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/query\_cache.rb:9:in `cache' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:28:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/connection\_adapters/abstract/connection\_pool.rb:361:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/params\_parser.rb:15:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/cookie_store.rb:93:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/failsafe.rb:26:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/dispatcher.rb:114:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/dispatcher.rb:108:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb:17:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content\_length.rb:13:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in `call' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in `process' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:159:in `process\_client' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in `each' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in `process\_client' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in `run' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in `initialize' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in `new' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in `run' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in `initialize' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in `new' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in `run' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:34:in `run' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:111 &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:31:in `gem_original_require' &nbsp;&nbsp;&nbsp;&nbsp;C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' &nbsp;&nbsp;&nbsp;&nbsp;script/server:3

Any suggestions?

Thanks, Snowdall

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [May 18, 2010, 1:46pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/7 "2010-05-18T13:46:24Z")

</div>

Clark Snowdall wrote:

> It seems my message got cut off. What I wanted to include was the error log from when I accessed [http://localhost:3000/Contacts](http://localhost:3000/Contacts)
> 
> Here it is:
> 
> /!\ FAILSAFE /!\ Mon May 10 09:32:43 -0700 2010 &nbsp;&nbsp;Status: 500 Internal Server Error &nbsp;&nbsp;S1090 (0) [Microsoft][ODBC Driver Manager] Invalid string or buffer length

> Any suggestions?
> 
> Thanks, Snowdall

Hi,

Can you please post your database.yml it seems like your gems are set up correctly. I would check the odbc and database.yml settings.

---

<div class="post-metadata">

**Author:** ![Jason11](https://avatars.discourse-cdn.com/v4/letter/j/b4bc9f/32.png) [@Jason11](https://discuss.rubyonrails.org/u/Jason11)\
**Post date:** [May 19, 2010, 1:18am UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/8 "2010-05-19T01:18:12Z")

</div>

this may help [http://www.codecapers.com/post/A-Ruby-on-Rails-Tutorial-for-NET-Developers.aspx](http://www.codecapers.com/post/A-Ruby-on-Rails-Tutorial-for-NET-Developers.aspx)

Jason

---

<div class="post-metadata">

**Author:** ![Gordon\_Yeong](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@Gordon\_Yeong](https://discuss.rubyonrails.org/u/Gordon_Yeong)\
**Post date:** [May 25, 2010, 12:06am UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/9 "2010-05-25T00:06:30Z")

</div>

guys,

It's interesting. Did the post below solve the problem?

---

<div class="post-metadata">

**Author:** ![pepe1](https://avatars.discourse-cdn.com/v4/letter/p/dec6dc/32.png) [@pepe1](https://discuss.rubyonrails.org/u/pepe1)\
**Post date:** [May 25, 2010, 2:27pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/10 "2010-05-25T14:27:16Z")

</div>

> guys,
> 
> It's interesting. Did the post below solve the problem?

Not for me. I am still working on getting the connection working, although I have not spent too much time on it. I am using SQL Server 2005, though, and I know pretty much nothing about SQL Server so it's being a little bit of a learning curve to set this up.

So far I have installed DBI and activerecord-sqlserver-adapter (2.3.5). After I did that I tried to use mode ADO and got this:

NotImplementedError: Please use version 2.3.1 of the adapter for ADO connections. Future versions may support ADO.NET.

So I installed 2.3.1 instead and got this when starting the console (but it let me in):

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/ connection\_adapters/abstract/connection\_specification.rb:76:in `establish_connection':RuntimeError: Please install the sqlserver adapter: `gem install activerecord-sqlserver-adapter` (no such file to load -- deprecated)

and this when trying to instantiate a new record for a table:

ActiveRecord::ConnectionNotEstablished: ActiveRecord::ConnectionNotEstablished from c:/ruby/lib/ruby/gems/1.8/ gems/activerecord-2.3.5/lib/active\_record/connection\_adapters/abstract/ connection\_pool.rb:326:in `retrieve\_connection'

Seeing this amount of "success" I switched back to 2.3.5 and changed the mode to ODBC, but the DSN parameter gave me trouble. Now I think the DSN is OK (not sure, though):

dsn: Driver={SQL Server};Server=\<server\_name\>

where \<server\_name\> is the server name showing in the Connection Properties window off the DB Management application (Microsoft SQL Server Management Studio Express).

I think the DSN is OK because of the error I am getting now, which could indicate that I have passed the DSN problem but there is something else going on. Now starting the console gives no errors but I can't get to the tables (testing from the console with a 'Table.new' command):

ODBC::Error: S1090 (0) [Microsoft][ODBC Driver Manager] Invalid string or buffer length

I have checked on error S1090 and this is what I found:

SQLExecute &nbsp;&nbsp;&nbsp;&nbsp;S1090 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Invalid string or buffer length. One of the following situations:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* Parameter pointer is null and length does not equal SQL\_NULL\_DATA. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* Parameter is not null and length is equal to SQL\_NULL\_DATA. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* Parameter is not null, length is negative, length is not equal to SQL\_NULL\_DATA, and length is not equal to SQL\_NTS.

I seems to me like some type of "configuration" error. If anybody has an idea of what could be going on I would appreciate any help and if I get a connection working I'll make sure I post here the steps it took me to make it work.

---

<div class="post-metadata">

**Author:** ![Nick\_Sieger](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@Nick\_Sieger](https://discuss.rubyonrails.org/u/Nick_Sieger)\
**Post date:** [May 25, 2010, 3:46pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/11 "2010-05-25T15:46:47Z")

</div>

Have you tried using JRuby with activerecord-jdbcmssql-adapter? We've heard multiple stories from folks having better luck using JRuby to connect to SQLServer than with the buggy ODBC driver.

/Nick

---

<div class="post-metadata">

**Author:** ![pepe1](https://avatars.discourse-cdn.com/v4/letter/p/dec6dc/32.png) [@pepe1](https://discuss.rubyonrails.org/u/pepe1)\
**Post date:** [May 25, 2010, 3:54pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/12 "2010-05-25T15:54:33Z")

</div>

> Have you tried using JRuby with activerecord-jdbcmssql-adapter? We've heard multiple stories from folks having better luck using JRuby to connect to SQLServer than with the buggy ODBC driver.

The thought has crossed my mind, especially since I already wrote some time ago a Java app. that connected to SQL Server 2005 with no problem whatsoever and I am guessing JRuby could be using Java "stuff". I actually took a look at that code I wrote a while back to check out the connection string. The thing is that I have never created a JRuby application and I don't know if I want to go through the learning curve. I haven't really looked at JRuby at all and this project needs to get going pretty fast. Do you have any recommendations about JRuby documentation? Any comments about the learning curve?

Thanks!

---

<div class="post-metadata">

**Author:** ![Nick\_Sieger](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@Nick\_Sieger](https://discuss.rubyonrails.org/u/Nick_Sieger)\
**Post date:** [May 25, 2010, 4:29pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/13 "2010-05-25T16:29:08Z")

</div>

> > Have you tried using JRuby with activerecord-jdbcmssql-adapter? We've heard multiple stories from folks having better luck using JRuby to connect to SQLServer than with the buggy ODBC driver.
> 
> The thought has crossed my mind, especially since I already wrote some time ago a Java app. that connected to SQL Server 2005 with no problem whatsoever and I am guessing JRuby could be using Java "stuff". I actually took a look at that code I wrote a while back to check out the connection string. The thing is that I have never created a JRuby application and I don't know if I want to go through the learning curve. I haven't really looked at JRuby at all and this project needs to get going pretty fast. Do you have any recommendations about JRuby documentation? Any comments about the learning curve?
> 
> Thanks!

The experience should be identical to Ruby -- just substitute "jruby" for "ruby" in your command lines and that's about it, really. Just head over to jruby.org/downloads, grab a windows installer, and go.

The one difference is to "jruby -S gem activerecord-jdbcmssql-adapter" to install JRuby's SQLServer support. You'll also want to review one more step outlined here to run the "jdbc" generator:

[http://blog.nicksieger.com/articles/2009/10/12/fresh-0-9-2-activerecord-jdbc-adapter-release](http://blog.nicksieger.com/articles/2009/10/12/fresh-0-9-2-activerecord-jdbc-adapter-release)

Once you've run that generator, use "mssql" for the adapter name in database.yml.

Cheers, /Nick

---

<div class="post-metadata">

**Author:** ![pepe1](https://avatars.discourse-cdn.com/v4/letter/p/dec6dc/32.png) [@pepe1](https://discuss.rubyonrails.org/u/pepe1)\
**Post date:** [May 25, 2010, 4:40pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/14 "2010-05-25T16:40:38Z")

</div>

Hi Nick,

I just went for a little reading to [http://jruby.org/](http://jruby.org/) and although writing code in JRuby might not be different than writing in Ruby it seems that deploying the application might involve some other steps I am not familiar with.

My applications run in intranets with very few users and the setup we use is very simple: Mongrel as web service and deployment is just an application folder copy away. I'd like to keep things as simple as possible for now.

If I use JRuby, do I need to use GlashFish or can I still use Mongrel as my web server? Do I need to deploy using a .war file or can I just copy the application's folder as I am currently doing?

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![hassan](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/hassan/32/714_2.png) [@hassan](https://discuss.rubyonrails.org/u/hassan)\
**Post date:** [May 25, 2010, 5:47pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/15 "2010-05-25T17:47:29Z")

</div>

You can continue to use Mongrel (or the Glassfish gem or Trinidad (Tomcat) gem) with the same application folder layout you have now.

An app server/WAR file deployment is way overkill unless you need some other aspect of JEE architecture.

FWIW,

---

<div class="post-metadata">

**Author:** ![pepe1](https://avatars.discourse-cdn.com/v4/letter/p/dec6dc/32.png) [@pepe1](https://discuss.rubyonrails.org/u/pepe1)\
**Post date:** [May 25, 2010, 5:53pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/16 "2010-05-25T17:53:03Z")

</div>

Thanks Hassan (and Nick).

I am going to see if I can get something running quickly in JRuby.

---

<div class="post-metadata">

**Author:** ![pepe1](https://avatars.discourse-cdn.com/v4/letter/p/dec6dc/32.png) [@pepe1](https://discuss.rubyonrails.org/u/pepe1)\
**Post date:** [May 25, 2010, 8:51pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/17 "2010-05-25T20:51:05Z")

</div>

> The one difference is to "jruby -S gem activerecord-jdbcmssql-adapter" to install JRuby's SQLServer support. You'll also want to review one more step outlined here to run the "jdbc" generator:

Hi Nick,

Got the adapter installed (your command was missing the word 'install', though) but now I am getting errors. After running this command:

jruby -S rails my\_app

I get this message:

c:/jruby-1.5.0/lib/ruby/site\_ruby/1.8/rubygems.rb:777:in `report\_activate\_error': Could not find RubyGem rails (\>= 0) (Gem::LoadError)

???

I noticed that rubygems are coming from the 'site\_ruby' instead of the 'gems' folder. I tried to remove the rubygems from 'site\_ruby' to see if that would work but there was no difference

I am kind of confused...

---

<div class="post-metadata">

**Author:** ![Nick\_Sieger](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@Nick\_Sieger](https://discuss.rubyonrails.org/u/Nick_Sieger)\
**Post date:** [May 25, 2010, 9:06pm UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/18 "2010-05-25T21:06:39Z")

</div>

> > The one difference is to "jruby -S gem activerecord-jdbcmssql-adapter" to install JRuby's SQLServer support. You'll also want to review one more step outlined here to run the "jdbc" generator:
> 
> Hi Nick,
> 
> Got the adapter installed (your command was missing the word 'install', though) but now I am getting errors. After running this command:

Oops, yes it was.

> jruby -S rails my\_app
> 
> I get this message:
> 
> c:/jruby-1.5.0/lib/ruby/site\_ruby/1.8/rubygems.rb:777:in `report\_activate\_error': Could not find RubyGem rails (\>= 0) (Gem::LoadError)

You'll need to re-install the Rails gem as well.

/Nick

---

<div class="post-metadata">

**Author:** ![Matt\_Jones](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@Matt\_Jones](https://discuss.rubyonrails.org/u/Matt_Jones)\
**Post date:** [May 26, 2010, 2:07am UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/19 "2010-05-26T02:07:51Z")

</div>

I just recently got a Rails 2.3.5 app up on SQL Server 2005 using ODBC mode, and the DSN I ended up using was the name specified in the "Data Sources" control panel as a system DSN. I also had no end of trouble until I added the login info to the (supposedly optional) "Use this username and password to connect to the DB for additional configuration" [paraphrasing] area.

There was also the mess from running 32-bit Ruby on Windows Server 2008 - the regular control panel created a DSN that couldn't be seen from Ruby. I \*finally\* found these directions:

[http://www.boche.net/blog/index.php/2009/11/21/create-a-32-bit-vcenter-dsn-on-a-64-bit-operating-system/](http://www.boche.net/blog/index.php/2009/11/21/create-a-32-bit-vcenter-dsn-on-a-64-bit-operating-system/)

That pointed me to the 32-bit control panel I needed. Not exactly the easiest launch in the world...

--Matt Jones

---

<div class="post-metadata">

**Author:** ![pepe1](https://avatars.discourse-cdn.com/v4/letter/p/dec6dc/32.png) [@pepe1](https://discuss.rubyonrails.org/u/pepe1)\
**Post date:** [May 26, 2010, 2:15am UTC](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324/20 "2010-05-26T02:15:00Z")

</div>

Thanks for the info Matt.

I followed Nick's suggestions and instructions and using JRuby is ending up being way easier than using ODBC with Ruby. I got a connection up and running after I realized a couple of things and I am right now playing with it. I was getting a weird error about IDENTITY but I think I just figured out how to fix it.

When I finish I'll post here what I hope will be an easy guide to using JRuby with SQL Server.

[Next page](https://discuss.rubyonrails.org/t/sqlserver-on-rails/48324.md?page=2)
