-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_db2_connection.rb
More file actions
46 lines (34 loc) · 1.2 KB
/
test_db2_connection.rb
File metadata and controls
46 lines (34 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'sequel'
require 'pry'
# user = "EWTUSR02" ewtusr03
# password = "PASSWTR02" PASSWTR03
hostname = "173.10.10.10"
port = 8471
database = "EWTEST"
user = "EWTUSR02"
password = "PASSWTR02"
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: port, database: database, user: user, password: password, after_connect: lambda{|foo| puts foo})
end
puts " * connected"
binding.pry
test!