On Apr 25, 11:01 pm, Don Morrison <[email protected]> wrote: > Like I said, everything goes swimmingly when running Rails normally (i.e. no > Tomcat). On a side note, I'm using Trinidad for testing which is similar to > the glassfish gem in that it gives me a Tomcat environment without needing to > set it all up. As I was trying to figure out this problem, it occurred to me > that ActiveRecord was having no problem connecting to the same database - so > I went digging through activerecord-jdbc-adapter on GitHub, and I found this: > > def connection(url, user, pass) > Jdbc::DriverManager.getConnection(url, user, pass) > rescue > # bypass DriverManager to get around problem with dynamically loaded jdbc > drivers > props = java.util.Properties.new > props.setProperty("user", user) > props.setProperty("password", pass) > create.connect(url, props) > end > > (Link to this portion of the adapter on GitHub: > http://github.com/nicksieger/activerecord-jdbc-adapter/blob/master/li...) > > Looks like Tomcat/Trinidad is an environment where DriverManager isn't > working as expected. I took a stab at putting this into Sequel and here is > the topic branch for the fix:http://github.com/elskwid/sequel/tree/jdbc_fix
I'm not a JRuby/JDBC expert, but as long as this doesn't break any of my existing test suites, I'll apply it. > A quick explanation of what I did: > > * Added an attr_reader for the driver as we'll need to call the connect > method on it. > * Since the driver is "returned" from the database setup procs I just > grabbed it from there > * I used some of the code from the activerecord jdbc adapter > > I have no idea how I would add tests for this type of thing, so I didn't put > any in. If you have any thoughts, I will gladly work with them. I can't think of a good way to add automated tests for this. If it works when you use the patch, doesn't work without the patch, and the patch doesn't break anything, that's good enough for me. > When I was poking around, I noticed the use of the opts variable in the > connect method (in Sequel) [1] On line 167 I see this: > > args.concat([opts[:user], opts[:password]]) if opts[:user] && > opts[:password] > > But I don't see the opts being passed into the connect method. > > def connect(server) Sequel::Database#opts is an attr_reader. There does appear to be a problem with how server_opts is used, though I'm not sure it matters unless you are using a sharding configuration. Anyway, you can try the patch at http://pastie.org/936679.txt. > Perhaps something is missing? Anyway, I added the code that uses these > options but left it commented out as I didn't actually have an opts variable > to access. Take a look and let me know if I need to do anything more. Oh, I > can make a pull request too, if you like, and thanks for all the great work > on Sequel! I'll give your patch a shot and see how it affects things. Thanks for your help. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. 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.
