From: | senthil kumar <kumar(at)brainpowers(dot)co(dot)jp> |
---|---|
To: | peter(at)retep(dot)org(dot)uk |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | servlet problem |
Date: | 2002-05-09 06:00:09 |
Message-ID: | 20020509060012.312DB4758EC@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Dear Sir/Madam,
Below i have written my environment
installed FreeBSD 4.5
installed JDK1.3.1
installed Tomcat 3.2
installed Postgresql 7.2.1
installed JDBC-Postgre driver and placed the pgjdbc.jar file in
/jdk1.3.1/jre/lib/ext
servlet.jar file was located in /usr/local/tomcat/lib/servlet.jar
i am the beginer for the java world and postgresql.i don`t know how to
compile and run the below servlet program
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class Mypsql extends HttpServlet {
Connection conn;
Statement stmt;
//set the connection url,database username and password
String url = "jdbc:postgresql://localhost:5432/postgres";
String dbusername = "postgres";
String dbpass = "postgres";
public void init(ServletConfig config)throws ServletException{
super.init(config);
}
public void doGet(HttpServletRequest req, HttpServletResponse res)throws
ServletException, IOException{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
try
{
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection(url,dbusername, dbpass);
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT*FROM test1");
while(rs.next())
{
out.println(rs.getString(1)+ "<BR>");
}
}
catch(Exception e)
{
out.println(e);
}
}
}
i couldn`t find postgresql.jar file.
please any one help me !
Thanks in advance!
kumar
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2002-05-09 13:52:50 | Re: extended error codes in the JDBC driver |
Previous Message | Ron Snyder | 2002-05-08 23:54:56 | Re: Logging function calls to figure out lo_close log entr |