users@glassfish.java.net

Re: Creating a JNDI for MySQL ?

From: <glassfish_at_javadesktop.org>
Date: Thu, 18 Oct 2007 06:45:01 PDT

Oh, this is extremely simple and "JBossish" in GlassFish :)
Sorry that you are having trouble setting it up. First off, you don't need to do "external"
resource, which refers to a resource that is looked up using a naming service "external to
GlassFish". This is not the case here.

So, you just need to define a normal jdbc-resource and jdbc-connection-pool in the admin
console.

Alternatively:
- Look at: install-dir/lib/install/templates/resources/jdbc and you'll find a file named
  javadb_type4_datasource.xml
  This looks like:
[code]
<resources>
    <jdbc-connection-pool
        name="javadb_type4_pool"
        datasource-classname="org.apache.derby.jdbc.ClientDataSource"
        res-type="javax.sql.DataSource">
        <property name="user" value="DB_USER"/>
        <property name="password" value="DB_PASSWORD"/>
        <property name="databaseName" value="DATABASE_NAME"/>
        <property name="serverName" value="DB_HOSTNAME"/>
        <property name="portNumber" value="1527"/>
        <property name="connectionAttributes" value=";create=true"/>
    </jdbc-connection-pool>

    <jdbc-resource
        enabled="true"
        jndi-name="jdbc/javadb_type4"
        object-type="user"
        pool-name="javadb_type4_pool"/>
</resources>
[/code]
- Copy it somewhere and just change the values to suit your set-up. Save it as say
  /users/me/resources.xml.

- Invoke [b] install-dir/bin/asadmin add-resources /users/me/resources.xml[/b]
[Message sent by forum member 'km' (km)]

http://forums.java.net/jive/thread.jspa?messageID=240928