On Jun 22, 5:10 pm, Lorrin Nelson <[email protected]> wrote:
> I had a working connection to a Postgres db. Now I'm trying to use JNDI and 
> running into problems. Sequel connects but then cannot do useful work. 
> Judging by the trace, it seems like the PGconn munging magic in 
> sequel/adapters/postgres.rb hasn't been applied to the Connection. Perhaps 
> this a result of switching to having Tomcat provide the connection pool 
> rather than Sequel establishing its own connections and I need some way to 
> get Sequel to layer its initialization on top of the connections received 
> from Tomcat? Hrm.

Sequel requires that the connection objects that it operates with
represent a single underlying connection to the database.  If JNDI
violates that assumption, Sequel won't be able to work correctly with
it.  The JNDI support in Sequel was contributed by others, I don't
have any personal experience with it.  I haven't tested it to make
sure it works (I don't know how), I've just tested to make sure it
didn't break the regular JDBC use.

> FWIW, the database URL I'm using is jdbc:jndi:java:comp/env/jdbc/my_db and I 
> defined the JDNI datasource in my Tomcat context.xml like this: <Resource 
> name="jdbc/my_db" auth="Container" type="javax.sql.DataSource" 
> maxActive="100" maxIdle="30" maxWait="10000" username="db_user" 
> password="password" driverClassName="org.postgresql.Driver" 
> url="jdbc:postgresql://localhost/mydatabase"/>
>
> java.util.concurrent.ExecutionException: 
> org.jruby.rack.RackInitializationException: undefined method `escape_string' 
> for #<#:0x4de35d1a>
> from 
> /Users/lhn/.rvm/gems/jruby-1.6.0/gems/sequel-3.21.0/lib/sequel/connection_pool/threaded.rb:84:in
>  `hold'
> from 
> /Users/lhn/.rvm/gems/jruby-1.6.0/gems/sequel-3.21.0/lib/sequel/database/connecting.rb:226:in
>  `synchronize'
> from 
> /Users/lhn/.rvm/gems/jruby-1.6.0/gems/sequel-3.21.0/lib/sequel/adapters/jdbc/postgresql.rb:91:in
>  `literal_string'

This particular backtrace appears to be that the JNDI connection
object does not implement escape_string, which the regular JDBC
postgres adapter does.  If the JNDI postgres adapter uses some other
name for this function, the JDBC postgres adapter should be updated to
use it for JNDI connections.

Hopefully someone more knowledgeable about JDBC/JNDI issues can chime
in with some advice.

Thanks,
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.

Reply via email to