Skip site navigation (1) Skip section navigation (2)

Re: POSTGRES JBDC PROBLEM

From: Bjørn T Johansen <btj(at)havleik(dot)no>
To: Iain <iain(at)mst(dot)co(dot)jp>
Cc: Chandra Mouli S <scmouli23(at)gmail(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: POSTGRES JBDC PROBLEM
Date: 2005-02-07 10:10:18
Message-ID: 42073E8A.1060004@havleik.no (view raw or flat)
Thread:
Lists: pgsql-jdbc
Or you could just place the jar file under $TOMCAT/common/lib and it should work... >(

BTJ

Iain wrote:
> Hi,
> 
> This is stretching my memory as I havn't touched tomcat for a while, but 
> I think that you should place the jar file in the tomcat deployment 
> directory with all the other jar files and class files that your 
> application uses.
> 
> In short, tomcat manages it's own class paths - or ateast it does so for 
> the applications deployed under it. Placing the jar file in the places 
> you did will never work as I understand it.
> 
> I hope that makes sense, and morover, I hope it helps,
> regards
> Iain
> 
> 
> ----- Original Message ----- From: "Chandra Mouli S" <scmouli23(at)gmail(dot)com>
> To: <pgsql-jdbc(at)postgresql(dot)org>
> Sent: Monday, February 07, 2005 3:17 PM
> Subject: [JDBC] POSTGRES JBDC PROBLEM
> 
> 
>> Hi,
>> SUB: Problem in JDBC with POSTGRESQL
>>
>> I have installed POSTGRESQL 8.0 beta on my WINDOWS XP SP2.
>>
>> It is perfectly working and I had created a database 'Student' with
>> table 'Details'
>>
>> The server is configured on PORT NO: 5432.
>>
>> I had unblocked the port no in IN-BUILT FIREWALL, to receive all 
>> requests.
>>
>>
>>
>> This is my Servlet program:
>>
>> *******************************************************
>>
>>
>> import javax.servlet.*;
>> import javax.servlet.http.*;
>> import java.io.*;
>> import java.sql.*;
>>
>> public class Stud extends HttpServlet {
>>
>> public void doPost(HttpServletRequest req, HttpServletResponse res) 
>> throws
>>
>> ServletException,IOException {
>>
>> try {
>>
>> int rNo=Integer.parseInt(req.getParameter("RegNo"));
>> String Qry="select * from details where RNo=" + rNo;
>> Connection con=null;
>> Statement st=null;
>> ResultSet rs=null;
>>
>> res.setContentType("text/html");
>>     PrintWriter pw =res.getWriter();
>>
>>
>> pw.println("<html>");
>>     pw.println("<body>");
>> pw.println("hellO");
>>
>> try
>> {
>> pw.println("STEP 1 ");
>>      Class.forName("org.postgresql.Driver");
>>
>> } catch(ClassNotFoundException cnfe)
>> {
>> pw.println("Exception CLASS NOT FOUND");
>> System.err.println("Count not find the Driver class");
>> cnfe.printStackTrace();
>> }
>>
>>
>>
>> con=DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/Student","scott", 
>>
>> "tiger");
>>  st=con.createStatement();
>>  rs=st.executeQuery(Qry);
>> rs.next();
>> int No=Integer.parseInt(rs.getString(1));
>> String Name=rs.getString(2);
>>
>>     pw.println(No);
>> pw.println(Name);
>>
>> pw.println("</body>");
>>     pw.println("</html>");
>> con.close();
>> st.close();
>> }
>> catch(Exception e) {
>> PrintWriter pw =res.getWriter();
>> pw.println(e);
>> }
>>
>>
>> }
>> }
>> ****************************************************************************************** 
>>
>>
>>
>> I had downloaded the latest postgresql driver
>> 'postgresql-8.0-310.jdbc3.jar ' from postgres.org
>>
>>
>> I had tried all these:
>>
>> 1) set the classpath to this particular jar file.
>>
>> 2) located the javahome directory thro 
>> HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java
>> Runtime Environment/*/JavaHome entry in registry  and placed my jdbc
>> jar file in that directory.
>>
>> ie c:\jre1.5.0_01\lib and \ext
>>
>> 3) placed my jdbc jar file in
>>   c:\jdk1.5.0_01\lib, c:\jdk1.5.0_01\jre\lib and \ext.
>>
>>
>> I my running TOMCAT SERVER 5.0 and when I invoke the servlet after 
>> passing the
>> parameter values from a HTML page,
>>
>> the following result in a new page is generated:
>>
>>
>> hellO STEP 1 Exception CLASS NOT FOUND java.sql.SQLException: No 
>> suitable driver
>>
>>
>>
>> The JVM is failing to locate the POSTGRESQL driver -  thro the
>>
>> Class.forName("org.postgresql.Driver"); command.
>>
>> The execution is not going beyond this command and hence the problem
>> is strictly with locating
>>
>> and using the POSTGRESQL driver for JDBC.
>>
>>
>> Hence I would like anyone of u to help me getting out of this trouble
>> as soon as possible.
>> I am in a tight project and because of this everything is pending.
>>
>> Please explain me in details all the problem in using JDBC for
>> POSTGRES in a WINDOWS PLATFORM.
>>
>>
>> If possible tell me place to get a correct POSTGRESQL JDBC driver...
>> all sites just point me to
>>
>> the jdbc.postgres.org page.
>>
>>
>>
>> Please help me as soon as possible.
>>
>>
>>
>> Yours truly,
>> Chandra Mouli.S
>> INDIA.
>>
>> scmouli23(at)gmail(dot)com
>> scmouli23(at)yahoo(dot)com
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org 
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

In response to

pgsql-jdbc by date

Next:From: Syed Abdul NasirDate: 2005-02-09 12:57:51
Subject: Fwd: Problem with deleting row
Previous:From: IainDate: 2005-02-07 09:59:50
Subject: Re: POSTGRES JBDC PROBLEM

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group