Connection to mysql using jsp/jdbc
Posted by: Arun Kumar
Date: February 20, 2006 01:46AM

hi everybody,
i m new to jsp and mysql. i m trying to authenticate a web application using jsp & mysql. userid and password is stored in a database "visitor" in table "login". i am running this application on sun appserver(j2ee). The error: Invalid Directive(login.jsp(4,5)) is displayed.follows is my code. tell me if i need tomcat or its ok with Sun Appserver.Please Solve my problem.


<HTML>
<HEAD>
<%@ PAGE import="java.io.*" import="java.lang.*" import="java.sql.*" %>
<TITLE>JSP Example 2</TITLE>
</HEAD>
<BODY>
<H1>JSP Example 3</H1>
<%
String uid, upwd, dpwd ;
Connection dbconn;
ResultSet results;
PreparedStatement sql;
TRY
{
Class.forname("org.gjt.mm.mysql.driver").newInstance();
TRY
{

dbconn = DriverManager.getConnection("jdbc:mysql://localhost/visitor","","");
uid = request.getParameter("userid");
upwd = request.getParameter("passwd");
sql = dbconn.prepareStatement("SELECT Password FROM login WHERE UseiId = '" + uid + "'");

results = sql.executeQuery();
dpwd = results.getString(Password);

if(upwd==dpwd)
{

}
else
{
out.println("Invalid Username or Password");
}
}
catch (SQLException s)
{
out.println("SQL Error<br>");
}
}
catch (ClassNotFoundException err)
{
out.println("Class loading error");
}
%>
</BODY>
</HTML>

Options: ReplyQuote


Subject
Written By
Posted
November 27, 2005 05:27AM
September 24, 2006 10:26AM
December 27, 2007 11:53PM
December 31, 2007 09:54PM
February 19, 2006 11:57PM
Connection to mysql using jsp/jdbc
February 20, 2006 01:46AM
b g
June 09, 2009 04:43AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.