File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Sun one application server and connection pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Sun one application server and connection pool" Watch "Sun one application server and connection pool" New topic
Author

Sun one application server and connection pool

ben ku
Greenhorn

Joined: Mar 30, 2004
Posts: 2
Hi,
I'm using SunOne AS7 and a mysql DB. I have a Java class that does all the work with the DB :

and so on.
I would like to use a connection pool but I don't know how to do that. On the admin pages of the app server, I've added a connection pool in Server1/JDBC/Connection Pools and I would like to know what I have to change in my code to use this connection pool.
thanks
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
Hi ben,
On Sun One,
Here is what I think should work,
1. First you have to configure connection pool as you already did
2. Configure "JDBC Resources" where you have to choose Connection Pool
and "JNDI Name" for the JDBC Resource ..e.g. jdbc/myJDBCResource
3. Use this JNDI Name to obtain the connection via,
java.sql.DataSource ds = (java.sql.DataSource)lookup("java:comp/env/jdbc/myJDBCResource");
Connection con = ds.getConnection();
....
...rest you know...
Also, look at this link, it should help you to see how to configure "resource-ref" entry in appropriate place like web.xml,sun-web.xml...
Regards
Maulin
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi ben,
also, from stand alone class it might not work as for stand alone class where would we configure "resource-ref" you know Anybody else knows if this can work? I am not yet an expert with Sun ONE...
you might have to create a servlet or jsp or session bean to do the operation...
Regards
Maulin
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
from the stand alone client you might have to drop java:comp/env from the lookup path and then use PROVIDER_URL and INITIAL_CONTEXT_FACTORY attributes set in the Conext env just as any other remote client...but I am not sure if it would work for jdbc resource...
Regards
Maulin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sun one application server and connection pool