找不到符号(java编译时错误)

时间:2014-02-22 09:26:56

标签: java servlets jdbc

我在tomcat服务器上运行我的servlet程序。我想在其中执行一些jdbc活动。 我在tomcat的lib文件夹中添加了连接器jar文件(需要jdbc)。我在这里发布了代码..

     import java.io.*;
 import javax.servlet.*;
 import javax.servlet.http.*;
 import java.sql.*;


 public class showAccounts extends HttpServlet
 {
  public void doGet(HttpServletRequest request, HttpServletResponse response)


  throws IOException, ServletException
  {
  response.setContentType("text/html");
  PrintWriter out = response.getWriter();


 Connection con;
 Statement st;
 ResultSet rs;

 try
  {
  Class.forName("com.mysql.jdbc.Driver");
  con=DriverManager.getConnection("jdbc:mysql://teamindia:3306/forjava?user=root&password=123");

   st=con.createStatement();
  rs=st.executeQuery("select * from users");


 while(rs.Next())
{
  out.println("<li>"+rs.getString(1));
  }
con.close();
  }
 catch(Exception e)
 {
 out.println(e); 
 }
  out.close();

 }

 }
编译时

我收到此错误

  error: cannot find symbol
  while(rs.Next())
      ^
  symbol:   method Next()
  location: variable rs of type ResultSet

有什么问题?

1 个答案:

答案 0 :(得分:0)

ResultSet next()没有Next()