Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Adelisa Fischer   on Jun 11 In Java Category.

  
Question Answered By: Frederick Greene   on Jun 11


<html>
<body>
<%@ page import="java.sql.*,java.io.*" %>
<%
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con
=

DriverManager.getConnection
("jdbc:oracle:thin:@suresh:1521:orcl","scott","tiger");
String username=request.getParameter("username");
String psw=request.getParameter("psw");
if(session.isNew())
{
session.setAttribute("username",username);
session.setAttribute("psw",psw);
}
PreparedStatement ps = con.prepareStatement("select psw from users");
ResultSet rs = ps.executeQuery();
//ps.setString(1,username);
rs.next();

ResultSetMetaData rsmd = rs.getMetaData();
int count = rsmd.getColumnCount();
String ret=new String();

ret=rs.getString(1);

if(psw.equals(ret))
{
%>
<h1>Welcome <%= username %>... </h1>
<%
}
else
{
response.sendRedirect("error.html");
}
%>
</body>
</html>

Solutions : put rs.next() before getting metadata

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Regarding Exhausted Resultset Exception Or get search suggestion and latest updates.