seenu vasu

Greenhorn
+ Follow
since Feb 03, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by seenu vasu

hi friends iam doing online project,using servlets and jsps
first i developed a login page which will call servlet,in servlet i will get
the form details (consists of username and password) and using this form details i will get the details of user which i already stored before in oracle database.and finally i compare with form password with database password(which i already stored before in oracle database).and then i capture this details in a bean.if password is not equal agail i call login html page.problem is iam unable to retrieve data from database even if i give correct username and password. iam giving source code below
plzzzzzzzzzzz friends help me in this regard
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class LoginSrv extends HttpServlet {
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
Connection con=null;
PrintWriter out=null;
res.setContentType("text/html");
out=res.getWriter();
pack.AccountBean abean=new pack.AccountBean();
try
{

Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc racle:thin:@localhost:1521 rcl","scott","tiger");
Statement stm=con.createStatement();
String un=req.getParameter("uname");
String q="select * from user_acc where username='" + un + "'";

ResultSet rs=stm.executeQuery(q);
out.println(rs);
out.println("before if part");
if(rs.next())
{
out.println("in if part");
String pass=rs.getString("password");
String pw=req.getParameter("password");
String fname=rs.getString("firstname");
String lname=rs.getString("lastname");
String email=rs.getString("email");
String street=rs.getString("street");
String city=rs.getString("city");
String state=rs.getString("state");
String country=rs.getString("country");
String telephone=rs.getString("telephone");
String card=rs.getString("card");
String cardno=rs.getString("cardno");
if(pw.equals(pass) )
{

abean.setUsername(un);
abean.setPassword(pw);
abean.setFirstname(fname);
abean.setLastname(lname);
abean.setEmail(email);
abean.setStreet(street);
abean.setCity(city);
abean.setState(state);
abean.setCountry(country);
abean.setTelephone(telephone);
abean.setPaymode(card);
abean.setCardnum(cardno);
req.getSession().invalidate();
HttpSession s=req.getSession(true);
s.setAttribute("acc",abean);

out.println("<html> <body bgcolor='yellow'> <center><font color=blue size=6> Login successful " +
"<br> Redirecting To Home Page </font> </center></div></body></html>");



RequestDispatcher rd=req.getRequestDispatcher("home.jsp");
rd.include(req,res);

}
else
{
RequestDispatcher rd=req.getRequestDispatcher("login.html");
rd.include(req,res);
out.println("in else part1");
}
}


else
{
RequestDispatcher rd=req.getRequestDispatcher("login.html");
rd.include(req,res);
out.println("in else part2");
}
}
catch(Exception e)
{
out.println("Unknown Exception "+e);
}
}
}
iam unable to connect to mysql database.iam getting the following
error when iam running the program.
Exception in thread "main" java.sql.SQLException: Access denied for user: 'root@
localhost' (Using password: YES)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:771)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1229)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2544)
at com.mysql.jdbc.Connection.<init>(Connection.java:1474)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:266)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at DBTest.main(DBTest.java:13)
plezz help me n this regard
bye
seenu