Skip to main content

How to create a connection pool programmatically in glassfish 3.1.1

9 replies [Last post]
table1
Offline
Joined: 2007-09-08
Points: 0

I came across few links which mention that the connection pool in glassfish can be created programmatically using the AMX API. I am not able to figure out the jars required to execute the test case pointed out in the link. Specifically the classes under the package "com.sun.appserv.management."..
Where can I find the jar files bundling the AMX API and its implementation? Any help?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ss141213
Offline
Joined: 2005-03-30
Points: 0

Are you trying to do it inside the server or from a client?

Sahoo
On Friday 10 February 2012 11:47 AM, forums@java.net wrote:
> I came across few [1]links [2]which [3]mention that the connection
> pool in
> glassfish can be created programmatically using the AMX API. I am not
> able to
> figure out the jars required to execute the test case [4] pointed out
> in the
> link. Specifically the classes under the package
> "com.sun.appserv.management."..
> Where can I find the jar files bundling the AMX API and its
> implementation?
> Any help?
>
>
> [1]
> http://www.java.net/forum/topic/glassfish/glassfish/problems-creating-jd...
> [2]
> http://today.java.net/pub/a/today/2008/01/15/dynamic-load-balancing-in-g...
> [3]
> http://blogs.oracle.com/JagadishPrasath/entry/creating_jdbc_connection_p...
> [4]
> https://svn.java.net/svn/glassfish~svn/tags/3.1.1/tests/amx/src/org/glas...
>
> --
>
> [Message sent by forum member 'table1']
>
> View Post: http://forums.java.net/node/883418
>
>

table1
Offline
Joined: 2007-09-08
Points: 0

I wanted to try both. The main goal is to have the pool created when the web application deployed on that server is first accessed. To start with I was looking for a standalone client which connects to the server.

Would the implementation be different? I am currently facing problems in locating the AMX API & impl libraries.

ss141213
Offline
Joined: 2005-03-30
Points: 0

If you just want the pool to be created before the application uses it,
then you can use glassfish-resources.xml or @DataSourceDefinition (part
of Java EE standard and hence portable). Search net or this forum for
more information.

Sahoo
On Friday 10 February 2012 12:56 PM, forums@java.net wrote:
> I wanted to try both. The main goal is to have the pool created when the
> web application deployed on that server is first accessed. To start
> with I
> was looking for a standalone client which connects to the server.
>
> Would the implementation be different? I am currently facing problems in
> locating the AMX API & impl libraries.
>
>
> --
>
> [Message sent by forum member 'table1']
>
> View Post: http://forums.java.net/node/883418
>
>

table1
Offline
Joined: 2007-09-08
Points: 0

The reason I mentioned programmatic creation of the data source was because the data source configuration is determined at runtime. Hence I think @DataSourceDefinition would not suit the purpose.

Any thoughts on how can I execute a sample specified here using the AMX APIs for glassfish 3.1.1?

tmueller
Offline
Joined: 2005-10-31
Points: 0

Since you are writing new code, is there any reason you cannot use the
REST interface
for doing this?

http://docs.oracle.com/cd/E18930_01/html/821-2416/gjipx.html#scrolltoc

Tom

table1
Offline
Joined: 2007-09-08
Points: 0

I am new to REST. I will tryout making REST web service calls through java to create a connection pool. Will update this chain.

Thanks for the reply.

table1
Offline
Joined: 2007-09-08
Points: 0

I was able to create the connection pool using the REST (http:\\<glassfish-server-name>:4848\management\domain) & apache http client 4.1. How can I retrieve an instance of javax.sql.DataSource after it is created programmatically by the web application code?

table1
Offline
Joined: 2007-09-08
Points: 0

An additional question would be how to add properties detailing the server name, user, port number etc through the REST API where the request is made through JSON. How should the json string look like for adding properties during connection pool creation?

table1
Offline
Joined: 2007-09-08
Points: 0

Any inputs?