Skip to content

Instantly share code, notes, and snippets.

@olleolleolle
Last active November 14, 2016 18:27
Show Gist options
  • Select an option

  • Save olleolleolle/d729c4de703276953cdd267d575e2f95 to your computer and use it in GitHub Desktop.

Select an option

Save olleolleolle/d729c4de703276953cdd267d575e2f95 to your computer and use it in GitHub Desktop.
Sequel fixed a thing - here is a way to try that fix out - https://github.com/jeremyevans/sequel/commit/c65b4b48bbbe0f749abccf03a13da8e3fe534516
#!/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
@olleolleolle

Copy link
Copy Markdown
Author

Without the :respond_to?:

#<Sequel::JDBC::Database: "jdbc:postgresql://localhost:5700/my_thing" {:login_timeout=>1}>
driver is not blank
Java::OrgPostgresql::Driver
here!
in there!
Sequel::DatabaseConnectionError: NoMethodError: undefined method `message=' for #<Java::OrgPostgresqlUtil::PSQLException:0x58ee2272>
Did you mean?  message
          make_new at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool.rb:125
          make_new at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:228
         available at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:201
          _acquire at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:137
  block in acquire at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:151
     block in sync at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:282
       synchronize at org/jruby/ext/thread/Mutex.java:148
              sync at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:282
           acquire at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:150
              hold at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:106
       synchronize at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/database/connecting.rb:285
    server_version at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/adapters/shared/postgres.rb:501
    server_version at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/adapters/shared/postgres.rb:1814
        select_sql at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/dataset/sql.rb:229
              each at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/dataset/actions.rb:141
               map at org/jruby/RubyEnumerable.java:829
               map at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/dataset/actions.rb:392
  pg_class_relname at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/adapters/shared/postgres.rb:1059
            tables at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/adapters/shared/postgres.rb:577
   block in (root) at ./o.rb:27

With the :respond_to?:

#<Sequel::JDBC::Database: "jdbc:postgresql://localhost:5700/my_thing" {:login_timeout=>1}>
Sequel::DatabaseConnectionError: Java::OrgPostgresqlUtil::PSQLException: Connection to localhost:5700 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
          make_new at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool.rb:125
          make_new at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:228
         available at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:201
          _acquire at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:137
  block in acquire at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:151
     block in sync at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:282
       synchronize at org/jruby/ext/thread/Mutex.java:148
              sync at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:282
           acquire at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:150
              hold at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/connection_pool/threaded.rb:106
       synchronize at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/database/connecting.rb:285
    server_version at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/adapters/shared/postgres.rb:501
    server_version at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/adapters/shared/postgres.rb:1814
        select_sql at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/dataset/sql.rb:229
              each at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/dataset/actions.rb:141
               map at org/jruby/RubyEnumerable.java:829
               map at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/dataset/actions.rb:392
  pg_class_relname at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/adapters/shared/postgres.rb:1059
            tables at /Users/olle/.rvm/gems/jruby-9.1.6.0/bundler/gems/sequel-c65b4b48bbbe/lib/sequel/adapters/shared/postgres.rb:577
   block in (root) at ./o.rb:27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment