• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with retrieving data

 
Waqas Ahmed Siddiqui
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have succesfully set the database but the proble im having is that i am unable to retrieve information from my database.
The coding is as follow:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class test extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String u1="SELECT user,pass FROM id1";
db db1=new db();
db1.setConnection();
Connection con1=db1.getConnection();
try {
Statement st=con1.createStatement();
ResultSet rs1=st.executeQuery(u1);
out.println(rs1);
while(rs1.next())
{
out.println(rs1.getString(1));
}
}
catch(Exception e)
{out.println("<H1>"+e+"</H1>");
}
}
}
--------------------------------------------------
Note : here db is my methods class which is not shown here.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you would post a stack trace that'd give us more of a handle on the problem... use e.printStackTrace(out).
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic