Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Prefer class_eval to reopening Connection class
Browse files Browse the repository at this point in the history
* Should aid situation where JRuby extension (do_DRIVER_ext.jar) does
  not load and no Error is raised. (Re-)opening the class in these
  situations was causing an ArgumentError to be raised (because the
  correct #initialize method is not defined) rather than a constant
  missing error.
* Thanks to Peter Brant for helping diagnosis this behaviour.
* Remove overriden pool_size: this is now defined for JRuby in
  DataObjects::Pooling.

[#1122]

Signed-off-by: Alex Coles <alex@alexcolesportfolio.com>
  • Loading branch information
myabc committed Nov 18, 2009
1 parent 460eb35 commit da1b14f
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 106 deletions.
10 changes: 0 additions & 10 deletions do_derby/lib/do_derby.rb
Expand Up @@ -18,16 +18,6 @@
# which is currently not working as expected.
java_import driver

module DataObjects
module Derby
class Connection
def self.pool_size
20
end
end
end
end

else
warn "do_derby is only for use with JRuby"
end
10 changes: 0 additions & 10 deletions do_h2/lib/do_h2.rb
Expand Up @@ -19,16 +19,6 @@
# which is currently not working as expected.
java_import driver

module DataObjects
module H2
class Connection
def self.pool_size
20
end
end
end
end

else
warn "do_h2 is only for use with JRuby"
end
10 changes: 0 additions & 10 deletions do_hsqldb/lib/do_hsqldb.rb
Expand Up @@ -17,16 +17,6 @@
# which is currently not working as expected.
java_import driver

module DataObjects
module Hsqldb
class Connection
def self.pool_size
20
end
end
end
end

else
warn "do_hsqldb is only for use with JRuby"
end
24 changes: 9 additions & 15 deletions do_mysql/lib/do_mysql.rb
Expand Up @@ -26,22 +26,16 @@

if RUBY_PLATFORM =~ /java/

module DataObjects
module Mysql
class Connection
def self.pool_size
20
end

def using_socket?
@using_socket
end

def secure?
false
end
end
DataObjects::Mysql::Connection.class_eval do

def using_socket?
@using_socket
end

def secure?
false
end

end

end
15 changes: 0 additions & 15 deletions do_oracle/lib/do_oracle.rb
Expand Up @@ -114,18 +114,3 @@ def self.ruby_time_zone
end
end
end

if RUBY_PLATFORM =~ /java/

module DataObjects
module Oracle
class Connection
def self.pool_size
20
end

end
end
end

end
14 changes: 0 additions & 14 deletions do_postgres/lib/do_postgres.rb
Expand Up @@ -21,17 +21,3 @@
require 'do_postgres/version'
require 'do_postgres/transaction'
require 'do_postgres/encoding'

if RUBY_PLATFORM =~ /java/

module DataObjects
module Postgres
class Connection
def self.pool_size
20
end
end
end
end

end
16 changes: 7 additions & 9 deletions do_sqlite3/lib/do_sqlite3.rb
Expand Up @@ -24,16 +24,14 @@

if RUBY_PLATFORM =~ /java/

module DataObjects
module Sqlite3
class Connection
def self.pool_size
# sqlite3 can have only one write access at a time, with this
# concurrent write access will result in "Database locked" errors
1
end
end
DataObjects::Sqlite3::Connection.class_eval do

def self.pool_size
# sqlite3 can have only one write access at a time, with this
# concurrent write access will result in "Database locked" errors
1
end

end

end
27 changes: 4 additions & 23 deletions do_sqlserver/lib/do_sqlserver.rb
Expand Up @@ -288,31 +288,12 @@ def self.param_count cmd
# Register SqlServer JDBC driver
java.sql.DriverManager.registerDriver Java::net.sourceforge.jtds.jdbc.Driver.new

module DataObjects
module SqlServer
class Connection
def self.pool_size
20
end

def using_socket?
@using_socket
end
DataObjects::SqlServer::Connection.class_eval do

=begin
# REVISIT: Does this problem even exist for Sqlserver?
def character_set
# JDBC API does not provide an easy way to get the current character set
reader = self.create_command("SHOW VARIABLES LIKE 'character_set_client'").execute_reader
reader.next!
char_set = reader.values[1]
reader.close
char_set.downcase
end
=end

end
def using_socket?
@using_socket
end

end

end

0 comments on commit da1b14f

Please sign in to comment.