nithinks
True Techie
<%@ taglib prefix="c" uri="*java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="*java.sun.com/jsp/jstl/sql" %>
<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:3306/project","root","");
uid = request.getParameter("nme");
upwd = request.getParameter("pwd");
sql = dbconn.prepareStatement("SELECT anm FROM login WHERE nm='"+uid+"'");
results = sql.executeQuery();
dpwd="admin";
dpwd = results.getString("anm");
%>
<p><%= dpwd%></p>
<%
}catch (SQLException s)
{
out.println("SQL Error<br>");
}
}
catch (ClassNotFoundException err)
{
out.println("Class loading error");
}
%>
</BODY>
</HTML>
------------------------------------------
The above program gives SQL exception why? can you give me the corrected code?
<%@ taglib prefix="sql" uri="*java.sun.com/jsp/jstl/sql" %>
<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:3306/project","root","");
uid = request.getParameter("nme");
upwd = request.getParameter("pwd");
sql = dbconn.prepareStatement("SELECT anm FROM login WHERE nm='"+uid+"'");
results = sql.executeQuery();
dpwd="admin";
dpwd = results.getString("anm");
%>
<p><%= dpwd%></p>
<%
}catch (SQLException s)
{
out.println("SQL Error<br>");
}
}
catch (ClassNotFoundException err)
{
out.println("Class loading error");
}
%>
</BODY>
</HTML>
------------------------------------------
The above program gives SQL exception why? can you give me the corrected code?