title: JDBC and JSP Database connection
body: <p>Hey so I am a little confused at the moment.  I have a few system.out.print code in here just so I can find out what the problem is.  Anyway, here is the error I get, and it is caught in the try/catch that involves the actual SQL query.</p>
  
  <p>Anyway here is my code.</p>
  
  <p>JSP page</p>
  
  <pre><code>&lt;%@ page import="webtest.*" %&gt;
  &lt;%@ page import="java.sql.*" %&gt;
  &lt;%@ page import="java.io.*" %&gt;
  &lt;%@ page import="java.util.*"%&gt;
  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  
  &lt;%String username = request.getParameter("username");
  String password = request.getParameter("password");
  UserNameCheck unc = new UserNameCheck();
  %&gt;
  &lt;H1&gt;
  &lt;%=unc.LoginResults("select name,password from mattroepracticetable" +
          " where name='"+username+"' and password='"+password+"' ")%&gt;
  
  &lt;/H1&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the UserNameCheck class</p>
  
  <pre><code>package webtest;
  
  import java.sql.*;
  public class UserNameCheck{
  DWConnect dwc = new DWConnect();
  
  public String LoginResults(String sql){
  Statement stmt;
  ResultSet rslt;
  System.out.println(sql);
  String V=null;
  try{
      stmt = dwc.conn.createStatement();
      System.out.print(sql);
      rslt = stmt.executeQuery(sql);
      if (rslt.next()){
           V = rslt.getString("username");
          System.out.print("hey");
      }
      else V = "Invalid UserName or Password";
      System.out.print("not hey");
  }
  catch (Exception e){System.out.print(e);}
  return V;
  }
  }
  </code></pre>
  
  <p>Anyway the error I am receiving is as follows</p>
  
  <pre><code>select name,password from mattroepracticetable where name='MattRoe' and password='MattRoe' java.sql.SQLException: Invalid column name
  </code></pre>
  
  <p>However if I directly copy and paste the SQL expression to SQLplus, it works fine.<br>
  I know you are supposed to initialize a Database Connection in the jspinit, but I also thought you could do it this way.<br>
  If someone could explain where I went wrong, tell me how I can set this up through jspinit, or just how I can set this up in general, would be appreciated.</p>