----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

let's start by looking in your log files.
Whats in jserv.log, mod_jserv.log etc

//OLAS
Anshu wrote:

> ----------------------------------------------------------------
> BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
> WHEN YOU POST, include all relevant version numbers, log files,
> and configuration files.  Don't make us guess your problem!!!
> ----------------------------------------------------------------
>
> Hi,
>
> I am using RH Linux 6.2 with following:
> Apache/1.3.12 (Unix)
>  ApacheJServ/1.1.1
>  postgresql 6.5.3-6
>
> My problem is that the code given in heading A works but when I try to use it in a 
>servlet ( heading B) it fails to make connection to database.
>
> "Case A -works "
> import java.sql.*;
> public class data{
>   public data(){
>    String url="jdbc:postgresql://localhost:5432/pan01";
>    try{
>     Class.forName("postgresql.Driver");
>     Connection c= DriverManager.getConnection(url,"yyyyyy","xxxxxxx");
>    }catch (Exception e)
>       {System.out.println(e.getMessage());}
>    }
>
>  public static void main(String args[]){
>     data dat=new data();
>  }
> }
>
> "Case B -does not work"
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.sql.*;
> public class sample extends HttpServlet{
>   public void doGet(HttpServletRequest req,HttpServletResponse      res)throws 
>ServletException, IOException{
>   try {
>            res.setContentType("text/html");
>            PrintWriter out = res.getWriter();
>            Class.forName("postgresql.Driver");
>            String url = "jdbc:postgresql://localhost:5432/pan01";                  
>Connection con=                                                     
>DriverManager.getConnection(url,"yyyyyy","xxxxxxx");
>          }catch (Exception e){
>                  res.setContentType("text/html");
>                  PrintWriter out = res.getWriter();                                  
>   out.println("This is not working ");
>         }
>    }
> }
>
> If you have any idea why is it happening please let me know.
> Thanks!
> Anshu
>
> _____________________________________________________________
> TheFreeSite.com: Home of the Web's best freebies.
> http://www.thefreesite.com
>
> --
> --------------------------------------------------------------
> Please read the FAQ! <http://java.apache.org/faq/>
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Search Archives:
> <http://www.mail-archive.com/java-apache-users%40list.working-dogs.com/>
> Problems?:           [EMAIL PROTECTED]



--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search Archives: 
<http://www.mail-archive.com/java-apache-users%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to