• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Sun one application server and connection pool

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic