Re: username/password in node xml definition

From: Tomi NA (hefes..mail.com)
Date: Sun Feb 19 2006 - 14:31:28 EST

  • Next message: Cris Daniluk: "Re: username/password in node xml definition"

    On 2/19/06, Cris Daniluk <cris.danilu..mail.com> wrote:
    >
    > It shouldn't... you don't need to change anything in your app, since
    > you're using Cayenne and Cayenne is cool like that :) Just add a new
    > DataNode in the Modeler, use the JDNIDataSourceFactory, and point it
    > to the JNDI name you have created in server.xml (if using Tomcat, if
    > not - the name you have created however you do it in your particular
    > server)

    Here's what I've done in tomcat's server.xml (inside the
    <GlobalNamingResources> element):
        <Resource name="jdbc/zs2" auth="Container" type="javax.sql.DataSource"/>
        <ResourceParams name="jdbc/zs2">
            <parameter>
                <name>username</name>
                <value>xxxxx</value>
            </parameter>
            <parameter>
                <name>password</name>
                <value>xxxxxxx</value>
            </parameter>
            <parameter>
                <name>driverClassName</name>
                <value>net.sourceforge.jtds.jdbc.Driver</value>
            </parameter>
            <parameter>
                <name>url</name>
                <value>jdbc:jtds:sqlserver://192.168.0.3/zs2</value>
            </parameter>
            <parameter>
                <name>maxActive</name>
                <value>8</value>
            </parameter>
            <parameter>
                <name>maxIdle</name>
                <value>4</value>
            </parameter>
        </ResourceParams>

    I'd say I probably covered the tomcat configuration part. However, cayenne
    modeler's stairing me in the face and wants to know the new data node JNDI
    Location. I'm quite certain a part of what I should write here is jdbc/zs2,
    but I'm equaly certain that I should somehow let cayenne know which tomcat
    instance I'm referening to (= tomcat IP:port).

    The reason that you "should use JNDI" is because the theory is that
    > the guy configuring the production environment - tomcat, database, etc
    > - doesn't know Java and wouldn't begin to know where to set database
    > settings in your app, but with JNDI, he can just define the resource
    > in the app server. Honestly, I don't use it as often as I should...

    In my case, it's a requirement if I'm to provide any real data security (e.g.
    not security by obscurity).

    Just to be clear, JNDI doesn't require LDAP... LDAP certainly can

    Now this was news...good to know, thanks.

    provide the database connection information, but really you just need
    > to ensure that your production Tomcat deployment has the datasource
    > defined, and that you make the server.xml owned only by root (if you
    > really want it only accessible to root).

    That's the general idea, yes.

    It might require some tweaking for you to get it right the first time,
    > but it shouldn't be too difficult - really, there's less than 10 lines
    > of configuration that you need to do, and if you use the Tomcat admin
    > app and the Cayenne modeler, there's just clicking!

    Well, it seems to me I'm one line away from using a JNDI datasource...thanks
    Cris, your advice regarding this problem has been invaluable. Now...is there
    any chance we could solve the small matter of the JNDI Location information?
    :)

    t.n.a.



    This archive was generated by hypermail 2.0.0 : Sun Feb 19 2006 - 14:31:30 EST