rubysql-serverjdbcsequel

using sequel jdbc in ruby to connect to microsoft sql server 2012 - running into error com.microsoft.sqlserver.jdbc.SQLServerDriver not loaded


I am trying to connect to Microsoft sQL Server 2012 database in ruby using the sequel gem.

This is what I have

require "sequel:
require "activerecord-jdbcmssql-adapter"

@db = Sequel.connect("jdbc:sqlserver://<host>;database=<dbname>;user='<userid>';password='pwd'")

When I run this I get the error:

com.microsoft.sqlserver.jdbc.SQLServerDriver not loaded.

How do I load the driver?

Thanks!


Solution

  • You need to require the driver jar file manually before calling Sequel.connect: require 'path/to/sqljdbc4.jar'. This is true for all Sequel jdbc subadapters where there isn't a corresponding jdbc-* gem wrapping the jar.