Re: data source problem

2015-02-17 Thread Yaragalla Muralidhar
Ok. Thank you.

*Thanks and Regards,*
Muralidhar Yaragalla.

*http://yaragalla.blogspot.in/ *

On Tue, Feb 17, 2015 at 2:32 PM, André Warnier  wrote:

> Hi.
>
> Yaragalla Muralidhar wrote:
>
>> I have configured the datasource in serverhome/conf/context.xml but when i
>> am hosting my web app the servers conf/context.xml is not available so i
>> have copied context.xml into META-INF folder of web app but still i get
>> the
>> message like datasource info not found. how can i solve this?
>>
>>
> I do not know how to resolve that.  But I can tell you how you could
> improve your chances of getting help here.
>
> In case you have not noticed, this is the Tomcat Users list, not Twitter
> or Facebook.
> So here, it helps if you think somewhat before firing off whatever comes
> to your fingers.
> First, read this : http://www.catb.org/esr/faqs/smart-questions.html
> It helps, in a general sense.
>
> Then, read the Tomcat on-line documentation, here :
> http://tomcat.apache.org/
> (I would point you to the appropriate version, but unfortunately you do
> not provide any useful information about that either)
> Start with this : http://wiki.apache.org/tomcat/FAQ
> and read the first few lines, they have useful recommendations.
> Then maybe search for "database" and "application deployment" ?  (there
> are even some examples there).
>
> The general idea is this : First, read the appropriate documentation to
> see how you are *supposed* to do this.  Then, if it does not work, make an
> effort at finding out why, using the available on-line resources.
> Then, if you still need help from this list, provide some *useful and
> precise* information about what you have tried, with what version of
> Tomcat, on which platform, according to what documentation.  And when it
> does not work, instead of mentioning a "message like..", copy the real
> message from the real logfile.
> All of that would immensely increase your chances of getting help quickly
> on this list.
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: data source problem

2015-02-17 Thread André Warnier

Hi.

Yaragalla Muralidhar wrote:

I have configured the datasource in serverhome/conf/context.xml but when i
am hosting my web app the servers conf/context.xml is not available so i
have copied context.xml into META-INF folder of web app but still i get the
message like datasource info not found. how can i solve this?



I do not know how to resolve that.  But I can tell you how you could improve your chances 
of getting help here.


In case you have not noticed, this is the Tomcat Users list, not Twitter or 
Facebook.
So here, it helps if you think somewhat before firing off whatever comes to 
your fingers.
First, read this : http://www.catb.org/esr/faqs/smart-questions.html
It helps, in a general sense.

Then, read the Tomcat on-line documentation, here : http://tomcat.apache.org/
(I would point you to the appropriate version, but unfortunately you do not provide any 
useful information about that either)

Start with this : http://wiki.apache.org/tomcat/FAQ
and read the first few lines, they have useful recommendations.
Then maybe search for "database" and "application deployment" ?  (there are even some 
examples there).


The general idea is this : First, read the appropriate documentation to see how you are 
*supposed* to do this.  Then, if it does not work, make an effort at finding out why, 
using the available on-line resources.
Then, if you still need help from this list, provide some *useful and precise* information 
about what you have tried, with what version of Tomcat, on which platform, according to 
what documentation.  And when it does not work, instead of mentioning a "message like..", 
copy the real message from the real logfile.

All of that would immensely increase your chances of getting help quickly on 
this list.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



data source problem

2015-02-17 Thread Yaragalla Muralidhar
I have configured the datasource in serverhome/conf/context.xml but when i
am hosting my web app the servers conf/context.xml is not available so i
have copied context.xml into META-INF folder of web app but still i get the
message like datasource info not found. how can i solve this?


*Thanks and Regards,*
Muralidhar Yaragalla.

*http://yaragalla.blogspot.in/ *


RE: Servlet problem/Data Source Problem

2006-02-21 Thread GB Developer
Did you look in the catalina.out file for any thrown Exceptions?  You are
try/catching and then System.out.println'ing them. You should have seen a
SQLException trace of some sort, read inline below...


> -Original Message-
> From: Mark Whitby [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, February 21, 2006 7:38 AM
> To: Tomcat Users List
> Subject: Servlet problem/Data Source Problem
> 
>ResultSet rst = stmt.executeQuery("select id, chest from 
> testdata");

you're missing this:
 if (rst.next()) {

> blob = rst.getInt("chest");
 }

you're also missing a WHERE clause in the query. You'll select everything
from testdata, by rs.next() will only get you to the first row.  To process
all rows, you make it a "while (rst.next()) { ", but then it would have to
be some sort of concatenation operation instead of just
blob=rst.getInt("chest"), because of course, if you did 'while', blob would
only contain the *last* row. So if you're interested in just the first row
or just the last row, there are more efficient ways of obtaining them.


> address = "/testy.jsp?errorcode=" + blob;
> stmt.close();
> con.close();
> } catch(NamingException e){
> System.out.println(e.toString());
> } catch(SQLException sql){
> System.out.println(sql.toString());
> }
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Servlet problem/Data Source Problem

2006-02-21 Thread Mark Whitby

David,

Thanks very much for the tips.  I haven't yet got it in a package as I am 
just using this for testing at the moment though I had managed to find out 
about number 2 and 3 for myself.  Thanks for the hint though.


Now I have another problem with the following code:

import java.io.*;
import java.net.*;
import javax.sql.*;
import javax.naming.*;

import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;

/**
*
* @author Mark
* @version
*/
public class SearchServlet extends HttpServlet {

   /** Processes requests for both HTTP GET and 
POST methods.

* @param request servlet request
* @param response servlet response
*/
   public void processRequest(HttpServletRequest request, 
HttpServletResponse response)

   throws ServletException, IOException {

   String address = "/privacy.jsp";

   DataSource ds = null;
   InitialContext ctx = null;
   Connection con = null;
   Statement stmt = null;
   int blob = -1;
   try{
   ctx = new InitialContext();
   ds = (DataSource) ctx.lookup("java:comp/env/jdbc/TestDB");
   con = ds.getConnection();
   if (con != null){
   address = "/termsandconditions.jsp";
   }
   else {
   address = "/support.jsp";
   }
   stmt = con.createStatement();
   ResultSet rst =
   stmt.executeQuery("select id, chest from testdata");
   blob = rst.getInt("chest");
   address = "/testy.jsp?errorcode=" + blob;
   stmt.close();
   con.close();
   } catch(NamingException e){
   System.out.println(e.toString());
   } catch(SQLException sql){
   System.out.println(sql.toString());
   }

   RequestDispatcher dispatcher = 
request.getRequestDispatcher(address);

   dispatcher.forward(request, response);
   }

Now what I've done is tested it using the if statement above and it detects 
the changes there and the servlet redirects me to termsandconditions.jsp. 
I've done this for the connection, statement and result set and none return 
as being null.


However, when I remove the if statement the servlet never gets to the 
"address = "/testy.jsp?errorcode=" + blob;" line and just redirects me to 
the privacy.jsp page.  If the if statement is still in, it redirects me to 
the address within the != null part of that.


Any ideas why it isn't working and if the database connection is even 
working at all?  Is there a better way to test it?


Mark

- Original Message - 
From: "David Smith" <[EMAIL PROTECTED]>

To: "Tomcat Users List" 
Sent: Tuesday, February 21, 2006 12:42 PM
Subject: Re: Fw: Servlet problem


I get the impression you are a beginner at this.  Reading the servlet spec 
would go a long way in understanding how the servlet container works.  For 
the immediate problem:


1) Try to get SearchServlet in a package.  ie: 
com.mycompany.myproject.SearchServlet  This isn't strictly required for 
servlet classes, but excellent practice none the less.  You will need 
packaged classes for any supporting classes you develop.


2) Map your servlet to a unique url of it's own and not to the url of 
existing JSPs.  When you map your servlet to a url matching a jsp, the 
servlet is executed instead of the jsp per the mapping mechanism.


3) The action attribute of your form tag should be to the url you mapped 
your servlet to, not it's literal location at 
WEB-INF/classes/SearchServlet.  Resources inside of WEB-INF are not 
directly accessible from the user and you'll get an error if you attempt 
it.


After the servlet does it's thing, it can forward the request to one of 
your jsps as necessary.  The servlet spec can be found at 
http://www.jcp.org/en/jsr/detail?id=154


--David



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]