hai Travis,
You are closing the connection object(con) inside the while loop in
doPost().
move this (con.close()) statement outside the while loop and try.
i tested your code in my machine connecting to my database and i could see
record on screen
without any exception.

Regards,
ravi





-----Original Message-----
From: TravisFalls [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 11, 2000 9:25 AM
To: [EMAIL PROTECTED]
Subject: JDBC SQL Error


Hello,
I am throwing a General Error in my SQL Try/catch.  I have been looking at
this for hours and I don't have a clue what this general error is.  any
suggestions as to what it is or how to debug it?  this is the complete code
below.

regards,
Travis D. Falls
[EMAIL PROTECTED]



package com.thehartford.bside;


import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;
import java.util.*;



public class DB_Connection extends HttpServlet{
        public String Customeridhere;
        public String Passwordhere;
        public String FirstNamehere;
        public String LastNamehere;
        private Statement statement;
        private Statement stmt;
        public String Query= ("SELECT Customerid, FirstName, LastName,
Password FROM Customer_tbl WHERE Customerid =" + "'" + Customeridhere + "'"
+ "and Password = " + "'" + Passwordhere + "'");

        private java.sql.Connection connection;
        public java.lang.String Password ="superman";
        public String UserName="admin";
        public String URL ="jdbc:odbc:Customer_mdb";


public void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException {

        res.setContentType("text/html");
        PrintWriter out = res.getWriter();

        out.println("<html><head><title>JavaTime Store</title></head>");
        out.println("<body bgcolor='#F9F9F9' leftmargin='0' topmargin='0'
marginwidth='0' marginheight='0'>");
        out.println("<form name='myform' method='post'
action='/servlet/com.thehartford.bside.DB_Connection'><table width='630'
border='0' cellspacing='0' cellpadding='0' height='130' align='center'>");
        out.println("<tr><td height='43'> <table width='630' border='0'
cellspacing='0' cellpadding='0'><tr> ");
        out.println("<td colspan='3'> <div align='center'><font face='Arial,
Helvetica, sans-serif' size='3'><b><font size='5'>JavaTime");
        out.println("Music Store</font></b></font></div></td></tr><tr> <td
colspan='3'> <font face='Arial, Helvetica, sans-serif'></font></td>");
        out.println("</tr><tr> <td colspan='2'> <div align='right'> <font
face='Arial, Helvetica, sans-serif' size='2'>Enter ");
        out.println("Customer ID:</font><font face='Arial, Helvetica,
sans-serif' size='2'> </font></div></td><td width='339'><font face='Arial,
Helvetica, sans-serif' size='2'>");
        out.println("<input type='text' name='Customerid' size='30'
maxlength='100'>");
        out.println("</font></td></tr><tr> <td colspan='3'> <font
face='Arial, Helvetica, sans-serif' size='2'></font></td>");
        out.println("</tr><tr> <td colspan='2'> <div align='right'> <font
face='Arial, Helvetica, sans-serif' size='2'>Enter");
        out.println("Password:</font> <font face='Arial, Helvetica,
sans-serif' size='2'></font></div></td>");
        out.println("<td width='339'> <font face='Arial, Helvetica,
sans-serif' size='2'>");
        out.println("<input type='password' name='Password' size='30'
maxlength='100'>");
        out.println("</font></td>");
        out.println("</tr>");
        out.println("<tr> ");
        out.println("<td colspan='3'><font face='Arial, Helvetica,
sans-serif' size='2'></font></td>");
        out.println("</tr><tr> <td colspan='3'> <div align='center'><font
face='Arial, Helvetica, sans-serif' size='2'>Need to Register?</font>
</div>");
        out.println("</td></tr><tr> <td colspan='3'>&nbsp;</td></tr><tr> <td
colspan='3'> <div align='center'><font face='Arial, Helvetica, sans-serif'
size='2'>");
        out.println("<input type='submit' name='Submit'
value='Submit'><input type='reset' name='Reset'
value='Reset'></font></div>");

out.println("</td></tr></table></td></tr></table></form></body></html>");
        }

public void doPost(HttpServletRequest req, HttpServletResponse res)
                                           throws ServletException,
IOException{
String Customeridhere;
String Passwordhere;
String FirstNamehere;
String LastNamehere;

        res.setContentType("text/html");
        PrintWriter out = res.getWriter();

                String name = "Customerid";
        Customeridhere = req.getParameter(name);
                String pass = "Password";
        Passwordhere = req.getParameter(pass);
        out.println(Query);
        try{
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          Connection con = DriverManager.getConnection(URL, "admin",
"superman");
          Statement stmt = con.createStatement();
          ResultSet resultset = stmt.executeQuery(Query);

                out.println("<html><head><title>Java Music
Store</title></head><body><table>");
                while (resultset.next()) {
                Customeridhere = resultset.getString("Customerid");
                Passwordhere = resultset.getString("Password");
                FirstNamehere = resultset.getString("FirstName");
                LastNamehere = resultset.getString("LastName");
                out.println("<tr><td>"+FirstNamehere+"</td></tr>");
                con.close();
                }
                out.println("</table></body></html>");
        }
        catch(SQLException e)
        {
          out.println("SQL Error in DBConnection one one one one 111111111"
+ e);
        }
        catch(ClassNotFoundException e)
        {
         out.println("Class not found in DBConnection two two two two two
2222222222 " + e);
        }
}

}

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to