n-ufla
Last Updated: February 25, 2016
·
1.619K
· krankin
8a70cf5765545ed6d8373e4ff16e7fa0

Connect to MSSQL named instance using JRuby and activerecord-jdbc-adapter

If you're like me, you have multiple instances of SQL Server running on your dev box (Sql Express, Enterpise, etc)..

Let's say you'rE creating a rails app and you need to connect to one of these instances specifically.

If you use the activerecord-jdbc-adapter gem, there is no parameter for instance name so what do you do? You could fork the repo, add instance name to the connection and submit a pull request... But you'll probably get rejected.. here's why.

According to msdn : http://msdn.microsoft.com/en-us/library/ms378428.aspx

"To connect to a named instance of SQL Server, you can either specify the port number of the named instance (preferred), or you can specify the instance name"

Here's an article outlining how to find the port number:
http://support.microsoft.com/kb/823938

Once you have that, specify the port in your database.yml file and if everything else is correct, you should be able to connect to your database.

Say Thanks
Respond