Here is an example using RESTful API:
http://blogs.steeplesoft.com/2011/03/managing-glassfish-jdbc-resources-via-rest/
--
Nazrul Islam - (408) 276-6468 - Oracle
forums_at_java.net wrote:
> I have been trying to programmatically create a JDBC connection pool in
> Glassfish V3.1 using AMX. The code we used for Glassfish V2 does not work
> under V3.1 and I can't seem to find any material that is helpful. Any
> advise/hints/tips would be most welcome. I understand that there have
> been
> changes in AMX for V3 and I've read the /GlassFish V3 AMX SPI/ [1] but
> that
> still didn't resolve my problem.
>
> The code that works under Glassfish V2 is:
>
> AppserverConnectionSource appserver =
> new
> AppserverConnectionSource(AppserverConnectionSource.PROTOCOL_RMI,
> GLASSFISH_HOSTNAME, GLASSFISH_JMX_PORT, GLASSFISH_USER,
> GLASSFISH_PASSWORD,
> null);
>
> DomainRoot domainRoot = appserver.getDomainRoot();
>
> domainRoot.getDomainConfig().createJDBCConnectionPoolConfig(connPoolName,
> "com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource", map);
>
>
>
> But under Glassfish V3.1 this throws the following exception:
>
> java.lang.RuntimeException: java.io.IOException: Failed to retrieve
> RMIServer stub: javax.naming.NameNotFoundException:
> management/rmi-jmx-connector
>
>
> [1]
> http://glassfish.java.net/nonav/v3/admin/planning/V3Changes/V3_AMX_SPI.html
>
>
> --
>
> [Message sent by forum member 'lostvicking']
>
> View Post: http://forums.java.net/node/822398
>
>