title: Inserting user data from JSP into postgres database
body: <p>I created a registered form of user information with JSP. I want to insert user data into a table with userinfo in postgre database after submitting form. But instead of adding data into this table, it gives me errors. Please help me!</p>
  
  <pre><code>&lt;%
  
      String fname = request.getParameter("fname");
      String lname = request.getParameter("lname");
      String email = request.getParameter("email");
      String user = request.getParameter("uname");    
      String pwd = request.getParameter("pass");
      String pwd2 = request.getParameter("pass2");
  
  
      Class.forName("org.postgresql.Driver");
      Connection con = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/UserInformation", "postgres", "123456789");
      PreparedStatement st = con.prepareStatement("insert into userinfo(firstname, lastname, email, username, password) VALUES ('" + fname + "','" + lname + "','" + email + "','" + user + "','" + pwd + "'");
  
  
      //ResultSet rs;
      int i = st.executeUpdate();
  
      if (i &gt; 0) {
          response.sendRedirect("welcome.jsp");
      } else {
          response.sendRedirect("login.jsp");
      }
  %&gt;
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>org.postgresql.util.PSQLException: ERROR: syntax error at end of input
    Position: 142
  </code></pre>