tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Adams <bad...@AEM-TX.com>
Subject RE: JDBC
Date Mon, 11 Feb 2002 12:53:58 GMT
where did you put your jdbc driver jar?  mine is named jdbc7.0-1.2.jar and
it is in my tomcat's common\lib directory.
B

-----Original Message-----
From: vinny patel [mailto:vinnyp121@hotmail.com]
Sent: Monday, February 11, 2002 6:48 AM
To: tomcat-user@jakarta.apache.org
Subject: RE: JDBC


this is the error message

**************************
Cant find database Driver class: java.lang.ClassNotFoundException: 
postgresql.Driver
SQL Exception java.sql.SQLException: No suitable driver
**************************

and heres the coding

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

  public class hotellist extends HttpServlet
  {
   public void doGet(HttpServletRequest req,
                     HttpServletResponse res)
   throws ServletException, IOException
   {
     res.setContentType("text/html");
     PrintWriter out = res.getWriter();
     String url =
       "jdbc:postgresql://dcsun2/dwt";
     String query = " select name,city from hotels order by city,name";

     out.println("<HTML>");
     out.println("<BODY>");


     try
     {
       Class.forName("postgresql.Driver");
     }
     catch(java.lang.ClassNotFoundException ex1)
     {
       out.println("Cant find database Driver class: " + ex1 +"<BR>");
     }

     try{
       Connection con = 
DriverManager.getConnection(url,"wwwuser","wwwuser");
       Statement stmt = con.createStatement();
       ResultSet rs =stmt.executeQuery(query);
       out.println("<P> <STRONG>Hotel ---   City</STRONG>");
       while (rs.next())
       {
         String hotelName = rs.getString(1);
         String cityName = rs.getString(2);
         out.println("<BR> " + hotelName + " , " + cityName);
       }
       out.println("</P>");
       stmt.close();
       con.close();
     }
     catch(SQLException ex2)
     {
       out.println("SQL Exception " + ex2);
     }
     out.println("</HTML>");
     out.println("</BODY>");
   }
}


*******************************

i believe it's something to do with the postgres driver?

cheers


>From: Brian Adams <badams@AEM-TX.com>
>Reply-To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
>To: 'Tomcat Users List' <tomcat-user@jakarta.apache.org>
>Subject: RE: JDBC
>Date: Mon, 11 Feb 2002 06:33:35 -0600
>
>what problems are you having?  can you post an error or code or both?
>B
>
>-----Original Message-----
>From: vinny patel [mailto:vinnyp121@hotmail.com]
>Sent: Monday, February 11, 2002 3:48 AM
>To: tomcat-user@jakarta.apache.org
>Subject: JDBC
>
>
>I am having problems with my servlets that connect to a postgres
>database. I am using the Tomcat 4, if anyone has any suggestions, i would 
>be
>
>gratefull!
>
>thanks
>
>_________________________________________________________________
>Join the world's largest e-mail service with MSN Hotmail.
>http://www.hotmail.com
>
>
>--
>To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
>Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
>
>--
>To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
>Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
>


_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message