Skip to content

Instantly share code, notes, and snippets.

@ruseel
Last active December 20, 2015 15:29
Show Gist options
  • Save ruseel/6154373 to your computer and use it in GitHub Desktop.
Save ruseel/6154373 to your computer and use it in GitHub Desktop.
jruby - ActiveRescord Example
require 'bundler/setup'
require 'active_record'
require 'activerecord-jdbc-adapter' if defined? JRUBY_VERSION
ActiveRecord::Base.establish_connection(
:adapter => 'jdbc',
:driver => 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
:url => 'jdbc:sqlserver://127.0.0.1:6231;DatabaseName=test',
:username => 'username',
:password => 'some_password'
)
class Students < ActiveRecord::Base
end
p Students.find(1)
source 'https://rubygems.org'
gem 'activerecord', '<= 3.2'
gem 'activerecord-jdbcmssql-adapter', :platform => :jruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment