Jdbc, jndi database connection strings


#1

Using normal jdbc connection string
“jdbc:postgresql://localhost/playdb?user=username&password=passwd”

What would the equivalent be for jndi connection if the jndi name was
“jdbc/pg_pool” when being used in a glassfish connection pool.
I am aware that the username and password are not required, because they
are incorporated in the glassfish pool setup.

I have found many references to using jndi in rails yaml setup, but no
info on the resultant string.

Thanks,
Paul F.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

Hello Paul,

I use the following for a pool called jdbc/my_pool in Glassfish:

production:
adapter: jdbc
jndi: jdbc/my_pool
driver: com.mysql.jdbc.Driver
encoding: utf8

Regards,

Martijn

Paul F.-5 wrote:

info on the resultant string.


View this message in context:
http://www.nabble.com/jdbc%2C-jndi-database-connection-strings-tp21598651p21600613.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#3

Martijn S wrote:

Regards,

Martijn

Thanks, Martijn,

But I am looking for the string to use outside the rails type setup. I
am attempting to use sequel ORM and I think I need something like:-

DB = Sequel.connect(“jndi:jdbc:postgresql://jdbc/my_pool/playdb”)

Regards
Paul


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#4

I thought the answer was too obvious :slight_smile: Still, you should be able to use
the
same string.

Are you sure Sequel supports jndi names this way? I don’t see anything
in
the documentation that makes it look like that.

M.

Paul F.-5 wrote:

encoding: utf8
DB = Sequel.connect(“jndi:jdbc:postgresql://jdbc/my_pool/playdb”)


View this message in context:
http://www.nabble.com/jdbc%2C-jndi-database-connection-strings-tp21598651p21601322.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#5

On Thu, Jan 22, 2009 at 4:36 AM, Paul F. removed_email_address@domain.invalid
wrote:

JDBC connection strings are passed by sequel straight through to JDBC (as I
understand it) so I would imagine (hope) the string can be handled in JDBC
if of the correct format.
Of course I could be barking up the wrong tree with this approach, but I
vaguely remember seeing a string somewhere with “jndi” in it.
Rails must handle the yaml to produce the correct string so I suppose I need
to get my hands dirty in the rails code.

Activerecord-jdbc-adapter has the code to handle JNDI, so Sequel would
need to have something similar if it was to support it. The code looks
like this:

http://github.com/nicksieger/activerecord-jdbc-adapter/blob/310de0f32b9c4f68c272b78d58ce02fb4c8ea50f/lib/active_record/connection_adapters/jdbc_adapter.rb#L382-393

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#6

Martijn S wrote:

I thought the answer was too obvious :slight_smile: Still, you should be able to use the
same string.

Are you sure Sequel supports jndi names this way? I don’t see anything in
the documentation that makes it look like that.

M.

JDBC connection strings are passed by sequel straight through to JDBC
(as I understand it) so I would imagine (hope) the string can be
handled in JDBC if of the correct format.
Of course I could be barking up the wrong tree with this approach, but I
vaguely remember seeing a string somewhere with “jndi” in it.
Rails must handle the yaml to produce the correct string so I suppose I
need to get my hands dirty in the rails code.

Thanks
Paul


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#7

Nick S. wrote:

Activerecord-jdbc-adapter has the code to handle JNDI, so Sequel would
need to have something similar if it was to support it. The code looks
like this:

http://github.com/nicksieger/activerecord-jdbc-adapter/blob/310de0f32b9c4f68c272b78d58ce02fb4c8ea50f/lib/active_record/connection_adapters/jdbc_adapter.rb#L382-393

/Nick

Hi Nick,

Where in the Activerecord-jdbc-adapter is the environment set for the
“javax.naming.InitialContext.new”?

I am getting this error
“Need to specify class name in environment or system property, or as an
applet parameter, or in an application resource file:
java.naming.factory.initial”

Thanks
Paul F.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#8

On Sun, Feb 1, 2009 at 5:03 AM, Paul F. removed_email_address@domain.invalid wrote:

Hi Nick,

Where in the Activerecord-jdbc-adapter is the environment set for the
“javax.naming.InitialContext.new”?

I am getting this error
“Need to specify class name in environment or system property, or as an
applet parameter, or in an application resource file:
java.naming.factory.initial”

We don’t currently accept custom properties for the initial context,
as you can see in the code. If you want to specify them yourself, the
usual way (outside of an application server environment where they’re
normally set for you) is to put java.naming.factory.inital and related
properties inside a ‘jndi.properties’ file and put it somewhere on
your system classpath.

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#9

usual way (outside of an application server environment where they’re
normally set for you)
So using Glassfish V3 Prelude, the code should work as is, because
Glassfish should have set the context?
I should check with the glassfish forum for an answer as to why it is
not finding the jndi connection.

Thanks, Nick
Paul F.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#10

On Sun, Feb 1, 2009 at 5:01 PM, Paul F. removed_email_address@domain.invalid wrote:

If you want to specify them yourself, the
usual way (outside of an application server environment where they’re
normally set for you)

So using Glassfish V3 Prelude, the code should work as is, because Glassfish
should have set the context?
I should check with the glassfish forum for an answer as to why it is not
finding the jndi connection.

Sounds like a good idea. Perhaps the base v3-prelude install does not
contain the JNDI hierarchy.

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email