Hi,
I see 3 possible solutions:
- package sqljdbc4.jar into a gem, include this gem in your Gemfile, and
call sequel binary using 'bundle exec sequel -m ...'
- write a dedicated script like your first script, tweak ARGV and call
sequel binary using Gem.bin_path
- write a dedicated script like your first script and call Sequel::Migrator
directly
If you plan to reuse this in many projects, I suggest solution 1.
Solution 2 is easiest but dirty fix.
Solution 3 is best if no reuse.
Solution 1: please use google on how to craft gems :-)
There are many approaches on this: I would suggest you to use bundler to
generate an empty Gem skeleton, copy sqljdbc4.jar in lib and modify main
ruby file to require java and sqljdbc4.jar
Detailed solution 2:
%w[rubygems bundler/setup java sqljdbc4.jar sequel].each { |i| require i }
Java::com.microsoft.sqlserver.jdbc.SQLServerDriver
ARGV=%w[-m db/migrate jdbc:sqlserver://10.10.10.110
;databaseName=extract;user=username;password=secret] # quotes can be
removed, trailing semicolon also (untested)
load Gem.bin_path('sequel','sequel')
Detailed solution 3:
%w[rubygems bundler/setup java sqljdbc4.jar sequel].each { |i| require i }
Java::com.microsoft.sqlserver.jdbc.SQLServerDriver
db = Sequel.connect('jdbc:sqlserver://10.10.10.110
;databaseName=extract;user=username;password=secret')
Sequel.extension :migration
Sequel::Migrator.run db, 'db/migrate'
Please note I've not tested this on Sequel 4, so minor tuning might occur.
Good luck.
Christian
On Sun, Jul 28, 2013 at 12:23 AM, cootcraig <[email protected]> wrote:
>
> On linux with JRuby 1.7.4
> I have sqljdc4.jar from Microsoft on the CLASSPATH.
>
> ###############
> # This script works
> require 'rubygems'
> require 'bundler/setup'
>
> require 'java'
> require 'sqljdbc4.jar'
> require 'sequel'
>
> Java::com.microsoft.sqlserver.jdbc.SQLServerDriver
>
> db = Sequel.connect('jdbc:sqlserver://10.10.10.110
> ;databaseName=extract;user=username;password=secret;')
>
> db.fetch("SELECT top 10 * FROM Skill") do |row|
> puts row.to_s
> end
> ###############
>
> Running a migration I get this error:
>
> $ bin/sequel -m db/migrate 'jdbc:sqlserver://10.10.10.110
> ;databaseName=extract;user=username;password=secret;'
> Error: NameError: missing class or uppercase package name
> (`com.microsoft.sqlserver.jdbc.SQLServerDriver')org/jruby/javasupport/JavaUtilities.java:54:in
> `get_proxy_or_package_under_package'
>
> craig@virt-ubu-1:/opt/gcsww.com/cvlan_logger_2$ bundle show sequel
> /opt/rubies/jruby-1.7.4.dev/lib/ruby/gems/shared/gems/sequel-4.0.0
>
> Any thoughts on how to do this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "sequel-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sequel-talk.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.