help I have already gone from error to error with my code and in all the problem is related to "null", my conclusion is that the input of my form gives me a value null and not the one that I type.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.net.*;
import java.sql.*;
public class insert extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException
{
PrintWriter out = response.getWriter();
boolean exito=false;
Connection con=null;
try
{
response.setContentType("text/html");
HttpSession session=request.getSession(true);
String nombre=request.getParameter("nombre");
String url="jdbc:postgresql://localhost:5432/DBFormulario";
Class.forName("org.postgresql.Driver");
con=DriverManager.getConnection(url,"postgres","postgres");
String query="INSERT INTO Formulario (nom) VALUES ("+nombre+");";
out.println("Sentencia SQL: "+query);
Statement inst=con.createStatement();
inst.executeUpdate(query);
con.close();
inst.close();
exito=true;
out.println("<br>Conexion Exitosa a DBFormulario!!!<br>");
}
catch(Exception e)
{
out.println("<br>Hubo un problema !!!<br>"+e.getMessage());
e.printStackTrace();
out.println("<br>Hubo un problema !!!<br>"+e.getClass().getName()+": "+e.getMessage());
}
if (exito){
out.println ("<h3> Los datos han sido enviados !!! </h3>");
out.println ("<h3><a href=http://127.0.0.1:8080/FORMULARIO/index.jsp>Regresa a capturar...</a></h3>");
out.close();}}}