users@glassfish.java.net

Re: Creating a JNDI for MySQL ?

From: <glassfish_at_javadesktop.org>
Date: Thu, 18 Oct 2007 17:00:31 PDT

Hello lancea,

Thank you for the effort.
New to Glassfish, coming from the JBoss -world.
There it is enough to define a persistence.xml within you app ( unit-name and jndi )
like this:
[i]<?xml version="1.0" encoding="UTF-8"?>
<persistence>
   <persistence-unit name="company">
      <jta-data-source>jdbc/company</jta-data-source>
       <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
       </properties>
   </persistence-unit>
</persistence>[/i]

and putting the rest within the mysql-ds.xml - there I put the url to the database
and the username and password.
I got the advice to create a resource.xml and 'inject' it into glassfish with the following commando: >%GLASSFISH_HOME%\bin\asadmin add-resources resources.xml
there I must define a <res-type> which is javax.sql.Datasource.

Do you mean that I could skip the resource.xml
and use the domain instead !?
When loading the resources.xml with the 'add-resources'-command then the domain.xml gets updated. And it gets updated with the stuff I put in resource.xml:
here is an excerp:
<jdbc-resource enabled="true" jndi-name="jdbc/company" object-type="user" pool-name="mysql-pool"/>
And a connection-pool is created:
    <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="mysql-pool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
      <property name="user" value="root"/>
      <property name="url" value="jdbc:mysql://localhost:3306/smallcompany"/>
      <property name="password" value="root"/>
    </jdbc-connection-pool>


among other things ...
the datasource is _> datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"

'com.mysql.jdbc.jdbc2.optional.MysqlDataSource' differs from my JBoss-file.
my mysql-ds.xml in JBoss says:
<driver-class>com.mysql.jdbc.Driver</driver-class>

Any other suggestion ?

regards, i
[Message sent by forum member 'inkimar' (inkimar)]

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