This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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: 1865
posted
0
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
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: 1865
posted
0
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