Forum: JRuby jdbc, jndi database connection strings

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
63b8056f715d4bc8c1415c97613360f4?d=identicon&s=25 Paul Fraser (Guest)
on 2009-01-22 07:30
(Received via mailing list)
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 Fraser


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
4a72bb2b2e6831599b6a0864dae69bb1?d=identicon&s=25 Martijn S (Guest)
on 2009-01-22 10:31
(Received via mailing list)
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 Fraser-5 wrote:
> info on the resultant string.
>
>
>

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


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
63b8056f715d4bc8c1415c97613360f4?d=identicon&s=25 Paul Fraser (Guest)
on 2009-01-22 11:03
(Received via mailing list)
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
4a72bb2b2e6831599b6a0864dae69bb1?d=identicon&s=25 Martijn S (Guest)
on 2009-01-22 11:14
(Received via mailing list)
I thought the answer was too obvious :) 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 Fraser-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-connec...
Sent from the JRuby - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
63b8056f715d4bc8c1415c97613360f4?d=identicon&s=25 Paul Fraser (Guest)
on 2009-01-22 11:37
(Received via mailing list)
Martijn S wrote:
> I thought the answer was too obvious :) 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
526d60de6472502bb570a9df2842b33b?d=identicon&s=25 Nick Sieger (Guest)
on 2009-01-22 14:26
(Received via mailing list)
On Thu, Jan 22, 2009 at 4:36 AM, Paul Fraser <paulf@a2zliving.com>
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-ada...

/Nick

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
63b8056f715d4bc8c1415c97613360f4?d=identicon&s=25 Paul Fraser (Guest)
on 2009-02-01 12:04
(Received via mailing list)
Nick Sieger 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-ada...
>
> /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 Fraser

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
526d60de6472502bb570a9df2842b33b?d=identicon&s=25 Nick Sieger (Guest)
on 2009-02-01 21:58
(Received via mailing list)
On Sun, Feb 1, 2009 at 5:03 AM, Paul Fraser <paulf@a2zliving.com> 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
63b8056f715d4bc8c1415c97613360f4?d=identicon&s=25 Paul Fraser (Guest)
on 2009-02-02 00:03
(Received via mailing list)
> 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 Fraser




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
526d60de6472502bb570a9df2842b33b?d=identicon&s=25 Nick Sieger (Guest)
on 2009-02-02 15:27
(Received via mailing list)
On Sun, Feb 1, 2009 at 5:01 PM, Paul Fraser <paulf@a2zliving.com> 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
This topic is locked and can not be replied to.