Skip to content

Commit 65a3de0

Browse files
pierrekares
authored andcommitted
arjdbc: performance improvement in setup_jndi_factory
Implement JdbcConnectionFactory using the class & mixin pattern instead of using a block. See also jruby/jruby#1401 Signed-off-by: Pierre-Alexandre Meyer <[email protected]>
1 parent 5c71923 commit 65a3de0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/arjdbc/jdbc/connection.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,19 @@ def setup_jndi_factory
6767
Java::JavaxNaming::InitialContext.new.lookup(config[:jndi].to_s)
6868

6969
@jndi = true
70-
self.connection_factory = JdbcConnectionFactory.impl { data_source.connection }
70+
self.connection_factory = RubyJdbcConnectionFactory.new(data_source)
71+
end
72+
73+
class RubyJdbcConnectionFactory
74+
include JdbcConnectionFactory
75+
76+
def initialize(data_source)
77+
@data_source = data_source
78+
end
79+
80+
def new_connection
81+
@data_source.connection
82+
end
7183
end
7284

7385
def setup_jdbc_factory

0 commit comments

Comments
 (0)