-
-
Save bbozo/df9f5992e777b64984c22f67106e366b to your computer and use it in GitHub Desktop.
IBM_DB hang code
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 'sequel' | |
require 'pry' | |
hostname = "hostname" | |
port = 8471 | |
database = "db" | |
user = "user" | |
password = "password" | |
dsn = "DATABASE=#{database};HOSTNAME=#{hostname};PORT=#{port};PROTOCOL=TCPIP;UID=#{user};PWD=#{password};" | |
def test! | |
expected = [{:"00001"=>1}] | |
actual = DB["select 1 from SYSIBM.SYSDUMMY1"].map{|x| x} | |
if expected == actual | |
puts " * OK" | |
else | |
puts " * not OK, expected #{expected} got #{actual}" | |
end | |
end | |
if Object.const_defined?(:JRUBY_VERSION) | |
puts "Testing JRuby with JDBC::AS400" | |
require_relative 'lib/jt400.jar' | |
jdbc_url = "jdbc:as400://#{hostname}:#{port}/#{database};user=#{user};password=#{password};" | |
# DB = Sequel.connect(jdbc_url) | |
DB = Sequel.connect(adapter: 'jdbc', url: jdbc_url, after_connect: lambda{|foo| puts foo}) | |
else | |
puts "Testing YARV with IBMDB gem" | |
require 'ibm_db' | |
# DB = Sequel.connect("ibmdb://#{hostname}:#{port}/#{database}?user=#{user}&password=#{password}") | |
DB = Sequel.connect(adapter: 'ibmdb', host: "#{hostname}:#{port}", database: database, user: user, password: password, after_connect: lambda{|foo| puts foo}) | |
end | |
puts " * connected" | |
# at this point the JDBC driver will print out "OK" and the IBM driver will hang | |
test! | |
# equally, if you run the following line, it will also hang | |
IBM_DB.connect dsn, '', '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment