tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Schalk Neethling <sch...@volume4.com>
Subject Re: DataSource web.xml question
Date Wed, 09 Feb 2005 23:43:47 GMT
Jack

This is obviously if you are not using JNDI to lookup a datasource.

Schalk Neethling wrote:

> Jack
>
> Within a servlet I use the following:
>
> public class activateArticle extends HttpServlet {
>
>    public String DRIVER, URL, USER, PASS, message;
>              public void init() throws ServletException {
>        ServletContext context = getServletContext();
>        DRIVER = context.getInitParameter("DRIVER");
>        URL = context.getInitParameter("URL");
>        USER = context.getInitParameter("USER");
>        PASS = context.getInitParameter("PASS");
>        }
>
> HTH
>
> Jack Lauman wrote:
>
>> If I have a datasource in the context-param area of the web.xml file, 
>> how can it be called?
>>
>> <context-param>
>>    <param-name>jdbcDataSource</param-name>
>>    <param-value>java:comp/env/jdbc/RestaurantDS</param-value>
>> </context-param>
>>
>>
>> pageContext.
>> getServletContext().getInitParameter("insert-context-param-name-here");
>>
>> Doesn't work here...
>>
>> ....
>> private void initialize()
>> {
>>    try {
>>        Context ctx = null;
>>        DataSource ds = null;
>>        Connection conn = null;
>>        Result result = null;
>>        try {
>>            ctx = new InitialContext();
>>            ds = (DataSource)
>>                 ctx.lookup("java:comp/env/jdbc/RestaurantDS");
>>        } catch (Exception e) {
>>        System.out.println("DataSource context lookup failed: " + e);
>>    }
>>    try {
>>        conn = ds.getConnection();
>>        } catch (Exception e) {
>>        System.out.println("DataSource getConnection failed: " + e);
>>          e.printStackTrace();
>>    }
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
>>
>

-- 
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
emotionalize.conceptualize.visualize.realize
Landlines
Tel: +27125468436
Fax: +27125468436
Web
email:schalk@volume4.com
Global: www.volume4.com
Messenger
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_@hotmail.com

We support OpenSource
Get Firefox!- The browser reloaded - http://www.mozilla.org/products/firefox/
 
This message contains information that is considered to be sensitive or confidential and may
not be forwarded or disclosed to any other party without the permission of the sender. If
you received this message in error, please notify me immediately so that I can correct and
delete the original email. Thank you.



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message