System DSN not working when Rails app running as Local System (ala mongrel_service)

93 views
Skip to first unread message

revgum

unread,
Aug 18, 2010, 11:06:28 AM8/18/10
to Rails SQLServer Adapter
When I run the mongrel server in a command window everything works
fine, database connections are made and the app is running properly.
If I set the Windows Service to run my app by logged in with my user
credentials it works fine as well. However, when I set the Service to
run as Local System I cannot get the application to start and the log
file shows the following error;

Status: 500 Internal Server Error
IM014 (0) [Microsoft][ODBC Driver Manager] The specified DSN
contains an architecture mismatch between the Driver and Application
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-
adapter-2.3.4/lib/active_record/connection_adapters/
sqlserver_adapter.rb:775:in `initialize'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-
adapter-2.3.4/lib/active_record/connection_adapters/
sqlserver_adapter.rb:775:in `connect'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-
adapter-2.3.4/lib/active_record/connection_adapters/
sqlserver_adapter.rb:775:in `connect'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-
adapter-2.3.4/lib/active_record/connection_adapters/
sqlserver_adapter.rb:188:in `initialize'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-
adapter-2.3.4/lib/active_record/connection_adapters/
sqlserver_adapter.rb:26:in `new'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-
adapter-2.3.4/lib/active_record/connection_adapters/
sqlserver_adapter.rb:26:in `sqlserver_connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/connection_adapters/abstract/connection_pool.rb:223:in
`send'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/connection_adapters/abstract/connection_pool.rb:223:in
`new_connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/connection_adapters/abstract/connection_pool.rb:245:in
`checkout_new_connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/connection_adapters/abstract/connection_pool.rb:188:in
`checkout'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/connection_adapters/abstract/connection_pool.rb:184:in
`loop'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/connection_adapters/abstract/connection_pool.rb:184:in
`checkout'
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'

I am running on Windows 7 64bit, and I have tried using odbcad32.exe
to create the System DSN and the User DSN.

Can anyone lend a hand, what am I missing?

Ken Collins

unread,
Aug 18, 2010, 12:53:18 PM8/18/10
to rails-sqlse...@googlegroups.com

Another thought. Perhaps the string in your database.yml need a bit of ERB love so you can provide different strings to different ODBC depending on what is needed? I am assuming that what you have there is OK for x but not for y.

- Ken


On Aug 18, 2010, at 11:21 AM, Ken Collins wrote:

>
> Hey,
>
> FIrst I would use the latest 2.x adapter. I think that is 2.3.8, version 2.3.6 had changes that allowed you to use DSN's that do not contain a database. That said, I do not think you problem is adapter related but rather specific to what your dsn string is like in you database.yml and/or with your windows odbc. Perhaps look around on the github wiki articles or google for that specific error.
>
> Maybe somebody here too with Windows experience can chime in as well?
>
>
> - Ken

>> --
>> You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
>> To post to this group, send email to rails-sqlse...@googlegroups.com.
>> To unsubscribe from this group, send email to rails-sqlserver-a...@googlegroups.com.
>> For more options, visit this group at http://groups.google.com/group/rails-sqlserver-adapter?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
> To post to this group, send email to rails-sqlse...@googlegroups.com.
> To unsubscribe from this group, send email to rails-sqlserver-a...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rails-sqlserver-adapter?hl=en.
>

Ken Collins

unread,
Aug 18, 2010, 11:21:22 AM8/18/10
to rails-sqlse...@googlegroups.com

Hey,

FIrst I would use the latest 2.x adapter. I think that is 2.3.8, version 2.3.6 had changes that allowed you to use DSN's that do not contain a database. That said, I do not think you problem is adapter related but rather specific to what your dsn string is like in you database.yml and/or with your windows odbc. Perhaps look around on the github wiki articles or google for that specific error.

Maybe somebody here too with Windows experience can chime in as well?


- Ken

> When I run the mongrel server in a command window everything works

revgum

unread,
Aug 18, 2010, 1:45:06 PM8/18/10
to Rails SQLServer Adapter
I just tried 2.3.8 and the same thing occurs. The real oddity is that
the DSN works great when I run the server on the commandline
(presumably using the User DSN) and doesn't work when I run it as a
service using the Local System account (presumably the System DSN,
both User and System DSN have the same name).

Here is what my config for development looks like;

development:
adapter: sqlserver
mode: ODBC
dsn: myapp-dev
username: somelogin
password: somepass
database: myapp-dev

I tried making a new System DSN that did not have a database specified
with the same problem when running under Local System account as a
service..

Are there any aspects of my setup that are out of whack regarding what
you support so far?

Rich Cox

unread,
Aug 18, 2010, 1:58:52 PM8/18/10
to rails-sqlse...@googlegroups.com
I would get rid of the User DSN & just use the system dsn. To be honest, I quit even bothering to make user dsn's a long time ago.

Rich C.

revgum

unread,
Aug 18, 2010, 2:06:01 PM8/18/10
to Rails SQLServer Adapter
Good idea for sure, will be doing that!

I don't know why I started to look at the problem from a different
angle, but found the solution.. Actually the ODBC Data Source
Administrator application I was thinking I had to use (from %windir%
\system32\odbcad32.exe) was incorrect. When running the application as
a Windows Service I needed to have a System DSN setup for the 64bit
version of ODBC Data Source Administrator (%windir%
\SysWOW64\odbcad32.exe). I setup a System DSN using the correct ODBC
Data Source Administrator program and my app is working fine.. imagine
that!? :D

Thanks!
> > rails-sqlserver-a...@googlegroups.com<rails-sqlserver-adapte r%2Bunsu...@googlegroups.com>
> > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/rails-sqlserver-adapter?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Rails SQLServer Adapter" group.
> > To post to this group, send email to
> > rails-sqlse...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rails-sqlserver-a...@googlegroups.com<rails-sqlserver-adapte r%2Bunsu...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages