Ruby on Rails + Sql Server 2005 - ruby-on-rails

This has been addressed some time ago, but I've not had any luck following the steps outlined or advice suggested. Here's my situation:
I've installed SQL Server '05 and have another (non-Ruby) application utilizing it successfully.
I've got Rails up and running successfully (but only for MySQL.)
I've installed the Rails sqlserver adapter gem (as well as its dependencies.)
I've downloaded ADO.rb (now only available on older builds of Ruby-DBI) and placed it into c:\ruby\lib\ruby\site_ruby\1.8\DBD\ADO\ADO.rb.
I've configured database.yml to use the sqlserver adapter and pointed it towards my database with valid login information.
When I attempt to run a migration, I get the ugly 'Unable to load driver ADO (uninitialized constant DBI::DBD::ADO)' error.
Thanks immensely for any assistance.

So just make sure if you're working on Windows or Mac to set up an ODBC connection. You must indicate this explicitly in your database configuration for Rails.

Related

Sybase SqlAnywhere 12 connection hangs after first connection attempt is successful

I'm experiencing what I believe is an environment issue, but I'm at my end as far as debugging it. I'm attempting to connect to a Sybase SqlAnywhere from a Rails 3.2.13 app on the same network. This is working from a rails 2.8 app, but I desperately need to upgrade.
It seems that I can connect through the rails console to the database the very first time that I create my new ruby gem and gemset using RVM, but subsequent attempts simply hang with no response after an attempt to query the database. I believe the database connection is being established as I get an error when incorrect credentials are supplied. After a successful connection on the first attempt, I am unable to replicate the success by opening a new terminal tab, setting the same gem and gemset, sourcing the database, and issuing the same query in the rails console.
I'm using a rails32 branch of a fork of the sqlanywhere adapter since the database adapter hasn't been supported by Sybase for a little while, but it has reported success using the same setup and I don't think this is the root of my issue since I've successfully returned valid data in the trials with limited success.
I've compared the working and non-working environments with no apparent difference, but is there anything significantly different about the RVM environment after the initialization of the gem/gemset that could be getting in the way?

Ruby on Rails with sql server

There is a chance I will have to make a project using RoR with a SQL Server 2008 r2 database. Is there any complication with using sql server as opposed to mysql when it comes to developing with RoR?
The only difference between the mysql adapter and the SQLServer adapter is that the later depends on the freetds gem. And when you first setup up your connection, you may have to deal with some simple utilities that come with freetds to verify or debug the connection. Once you are connecting, there is no difference in the way you deal with the database, no where in your RoR code is ANYTHING specific to SQLServer vs. mysql, it's all handled by the SQLServer adapter and freetds.
Shouldn't be too much of an issue; see this screencast on Rails 3, Ruby 1.9.2, Windows 2008, and SQL Server 2008 by Xavier Shay.
If you do run into issues while working on this project, StackOverflow is always there to rescue you ;-)

Connecting to SQL Server 2005 from a ROR application in Ubuntu

I tried to connect to SQL Server from a ROR application in Ubuntu. For that I did the following things.
I installed the following libraries in my Ubuntu 10.04
unixodbc
unixodbc-dev
freetds-dev
libdbd-odbc-ruby
tdsodbc
After installing these, I created the dsn and made the required changes in odbc.ini and freetds.conf files.
Then I tested the connection using "tsql" like below
tsql -S <dsn name> -U <username> -P <pwd>
For this command, I am getting the following error
Adaptive Server is unavailable
I also checked the freetds log; it is saying "connection timedout".
I am sure that we are fine with the configurations (remote) in our SQL Server side.
When I run tsql -C it is saying TDS Version is 5. I am not sure how it is saying TDS 5, because I installed the latest FreeTDS version. And I don't know how to update my TDS version.
FYI, I heard that TDS version 5 can't be used for making connections with SQL Server. Is that right?
Please guide me
Thanks,
Neo
freetds.conf allows you to specify which version of the TDS protocol you want to use. Just add a tds version = 8.0 under the [global] section or the section you added for your server. If not specified, it defaults to version 5.0, which seems to be your case. For more info, look at http://www.freetds.org/userguide/freetdsconf.htm
I realize this is not an answer to your specific question, but it is some advice from the last time I tried to go from Linux to SQL Server. It was back in 2009, so it's possible something has changed since then.
Anyway, we had so much trouble with it we gave up and decided to use JRuby.
It resulted in very little effort to get the connection up and running using activerecord-jdbc-adapter and we've run into no problems with compatibility. (I take that back, there was one problem I had to fix where we were selecting limited rows in mssql from table with no primary key, identity column, or column named "id")
I have been able to get it working in the past doing it like you're trying to, but it was always a lot more effort than I had to go through with JRuby.

rails ODBC data source problem?

Here's an odd situation, if I open a command prompt and start the mongrel server then everything works swimmingly. ActiveRecord talks nicely to the MSSQL server using ODBC if I have a User-DSN defined. But if remove the User-DSN and set just an identical System-DSN then odbc bombs:
[Microsoft][ODBC Driver Manager] Data
source name not found and no default
driver specified
I am running Rails on Windows 2003 Server 64bit, using DBI 0.4.1, DBD-ODBC 0.2.4, Rails 2.3.4. I've tried using ODBC manager for 32bit and double-checked that the connection is working from the ODBC Administration panel. Does anyone have any ideas?
Frustrating! As it turns out, I had to use regedit to access HKLM/Software/ODBC/ODBC.INI children key (DSN) and changed the SQLServer driver there to be c:\windows\system32\SQLSRV32.dll. Even though the ODBC Administration Panel had this specified and its tests ran fine, it wasn't working until I tweaked the registry. So odd..
Hope it helps someone else in the future.
For me the problem was that I was entering the ODBC connections into the 64 bit version of the ODBC Data Source Administrator. When I went to
C:\Windows\SysWOW64\odbcad32.exe
, and re-entered the drivers here (the others were not there!), and all worked fine after that.
blog entry where I found this

OCIError (ruby on rails)

I am using rails freeze 1.2.3 to run a rails app. Because the app is on a remote machine, I used ssh tunnel (ssh -l -L) to show the app on my screen. When I ran it, it correctly prompted the login page, after I put in the info, I got this error:
OCIError in ServiceController
Error while trying to retrieve text for error ORA-12154
I have tried the same app on a different machine w/o using freeze (because that machine has rails version 1.2.3 while current one has 2.0.2). Is that where the error comes from?
Thanks.
That's an Oracle error. It sounds like your database setup is incorrect. Put the error number ORA-12154 in Google and you'll find some useful stuff.
ORA-12154 is a classic. As Sarah points out its nothing to do with your Rails or Ruby per se. ORA-12154 is generated when the Oracle Client can't connect to the oracle server. So most likely your setup is wrong in:
Your database.yml, if you can connect using tnsping or sqlplus (Oracle client utils) you probably just need to look at this.
Your Oracle networking setup, particularly your tnsnames.ora file (found in $ORACLE_HOME/network/admin if I remember correctly). This may need some extra help from a friendly DBA as the tnsnames.ora syntax has quirks. Check this link link text for more info.
Hope that helps.

Resources