Thread

  1. important question

    najeeb ahmed <najeeb_a_99@yahoo.com> — 2000-12-06T11:35:26Z

    Dear sir,
       we are finding it difficult to connect to
    postgresql database using the postgresql driver i.e.
    using jdbc connectivity..trying it on apache web
    server on linux
    otherwise in ordinary applications it is working fine.
    	Could u plz suggest us a remedy as soon as possible..
    thanking you sir,
    najeeb
       
    the pgm is here..
    import java.sql.*;
    	import javax.servlet.*;
    	import javax.servlet.http.*;
    	import java.io.*;
    	public class tester extends HttpServlet 
    	{
    		public void doGet(HttpServletRequest
    req,HttpServletResponse res) throws
    ServletException,IOException
    		{		
    			
    				res.setContentType("text/html");
    				PrintWriter pw=res.getWriter();
    							
    			try
    			{
    		Driver
    d=(Driver)Class.forName("postgresql.Driver").newInstance();
    		DriverManager.registerDriver(d);
    
    		java.sql.Connection
    con=DriverManager.getConnection("jdbc:postgresql:najeeb","najeeb","");
    				Statement st=con.createStatement();
    				ResultSet rs=st.executeQuery("select hi from
    test");
    
    				while(rs.next())
    				{	String str=rs.getString(1);pw.println(str); }
    		pw.close();rs.close();st.close();con.close();
    			}
    			catch(Exception ex)
    			{
    				         pw.println(ex);
    			}
    			
    		}
    	} 
    
    
    __________________________________________________
    Do You Yahoo!?
    Yahoo! Shopping - Thousands of Stores. Millions of Products.
    http://shopping.yahoo.com/