----------------------------------------------------------------
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!!!
----------------------------------------------------------------
please if somebody knows the answer of my problem, sen me a mail to:
[EMAIL PROTECTED]
thank yu
I made a small application to connect with a DataBase postgres on
command line. Everything worked well. When I do a similar program, but
in a servlet, the problems appear. I'm using the following:
Jserv 1.1.2
Apache 1.3.6
I have the following directories that I believe are vry importantas to
acces postgress from a servlet:
/usr/lib/pgsql/lib/postgresql.jar
/usr/local/JSDK2.0/lib/jsdk.jar
/usr/lib/apache/ApacheJserv.jar
After, I put the following lines on jserv.properties file
wrapper.classpat=/usr/lib/pgsql/lib/postgresql.jar
wrapper.classpat=/usr/local/JSDK2.0/lib/jsdk.jar
wrapper.classpat=/usr/lib/apache/ApacheJserv.jar
I have this problem during one week. I'm trying to run the following
servlet that I think is done right. Next the servlet and the exception
is:
InServlet: init
[12/10/2000 19:16:51:620 GMT+00:00] Error en ClassForName:
java.lang.ClassNotFoundException: postgresql.Driver
It means the servlet don't load postgresql.Driver, But If ido this
program om coomand line, it is loaded. Thanks in advance
///////////////////////////////////////////////////////////
import java.sql.*;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
*Esta clase lo que hace es recibir datos de un formulario del web y
meter, consultar o modificar
*los datos en la tabla tienda de postgres.
*
*@author dr7tbientu miralo y mira a ver s
*/
public class InServlet extends HttpServlet {
Connection con;
public void init(ServletConfig sc) throws ServletException {
super.init(sc);
//se carga el driver
try {
Class.forName("postgresql.Driver");
}catch (ClassNotFoundException ex) {
sc.getServletContext().log("Error en ClassForName:
"+ex.toString());
System.out.println(ex.toString());
}
//conectamos a la base de adatos
try{
con=DriverManager.getConnection("jdbc:postgresql:mydb",
"postgres", "");
}catch (SQLException ex) {
System.out.println(ex.toString());
}
}//fin init()
public void destroy() {
super.destroy();
try{
con.close();
}catch(SQLException e){
System.out.println("Imposible cerrarla
conexión"+e.toString());
}
}//fin destroy
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException {
String pvp, pbase;
response.setContentType("text/html");
pvp = request.getParameter("pvp");
pbase= request.getParameter("pbase");
Statement stm;
try{
stm = con.createStatement();
int numRowsUpdated = stm.executeUpdate("INSERT INTO tienda
VALUES ("+Integer.parseInt(pvp)+","+Integer.parseInt(pbase)+")");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Registro actualizado</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<H1>Operación realizada con exito</H1>");
out.println("<H3>Actualizadas"+numRowsUpdated +
"filas</H3>");
out.println("</BODY>");
out.println("</HTML>");
out.flush();
out.close();
}catch(Exception e){
try{
System.out.println(e.toString());
//System.out.println("Error en la actualización" +
e.getMessage());
//Este es el código que muestra un html en el navegador
y
que arrija un NullPointerException
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<HEAD>");
out.println("</HEAD>");
out.println("<body>");
out.println("Error: "+e.toString());
out.println("</body></html>");
out.flush();
out.close();
}catch(Exception ex){
System.out.println(e.getMessage());
}finally {
try{
stm = null;
}catch(Exception ex){}
}
}
}
}
///////////////////////////////////////////////////////////////////
--
--------------------------------------------------------------
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]