On Sunday, April 1, 2012 1:19:08 AM UTC-7, Christian MICHON wrote:

> yes, I was doing something wrong. I need to do this instead:
>
> conn = DB.synchronize {|co| co}
>
Note that while that may work in your case, it's not recommended, as it 
returns the connection to the pool while you are still using it.  You 
should be doing:

  DB.synchronize do |conn|
    stmt = conn.createStatement
    ...
  end

Basically, you need to restrict your use of the conn object to the inside 
of the block, so that the connection isn't returned to the pool until after 
you are done using it.  In a single threaded program, this doesn't matter, 
but it is important in a multithreaded program.

Anyway, I'm glad that it is working for you.  For other readers, when you 
need the maximum possible speed, using Database#synchronize and dealing 
with the connection object is generally fastest, short of writing a native 
extension in C/Java.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/eVgef6pJP_UJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to