- Install jruby (you may also need the package with JRE if is not already on your machine): http://jruby.org/download
- Install the sequel gem: gem install sequel
- Download the jdbc driver for SQL Server: http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774
- Copy the sqljdbc4.jar in step 3's download into your apps directory (your app with require this later)
- Copy the correct (32 bit or 64 bit) sqljdbc_auth.dll in step 3's download into your windows system32 folder
- See demo.rb below for example of use.
-
-
Save imweijh/c743c74441510e3a4cd76c0148135cc4 to your computer and use it in GitHub Desktop.
How to connect to Microsoft SQL Server with jruby on Windows using JDBC and Sequel Gem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "java" | |
require "rubygems" | |
require "sequel" | |
require "sqljdbc4.jar" #this files path may need to be relevate to file location | |
DB = Sequel.connect( | |
:adapter => "jdbc", | |
:url => "jdbc:sqlserver://doric-server5;database=ADCData_Doric;integratedSecurity=true" | |
# This is using integrated security, might want to pass username and password | |
# More Info at http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html | |
) | |
the_table = DB[:the_table_name.identifier] | |
puts the_table.to_csv |
Author
imweijh
commented
May 24, 2024
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment