Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby -G --dev
- $: << __dir__
- require 'java'
- require 'jdbc/postgres'
- require 'sequel'
- require 'sequel/adapters/jdbc'
- require 'thread'
- # Pre-requisite: Set up a failing "SQL server" to not connect to
- #
- # nc -l 5700
- $q = Queue.new
- # A broken "SQL Server"
- t0 = Thread.new do
- IO.popen("nc -l 5700") { |io| io.puts($q.read) }
- end
- # Connecting to it, using JDBC
- t1 = Thread.new do
- dsn = 'jdbc:postgresql://localhost:5700/my_thing'
- DB = p(Sequel.connect(dsn, login_timeout: 1))
- # Here, we *actually* connect to the jdbc connect() method
- p(DB.tables)
- end
- sleep 3
- $q.push ""
- t1.join
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement