#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    0
    Rep Power
    0

    Counting records in a database?


    this is my current code:

    Unfortunately it is not scrolling through all of the records in the database. It is stuck on the first record. Any clues??? Any alternative ways to do this??

    ____________________________________________________

    <%@ page import = "java.sql.*" %>
    </head>


    <body bgcolor="#FFFFFF" text="#000000">
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbcdbc:login");

    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
    ResultSet rs = stmt.executeQuery("SELECT * FROM People");


    String user_id = request.getParameter("userID");
    String pass_word = request.getParameter("pwd");

    while( rs.next() )
    {

    String email = rs.getString("Email");

    if (user_id.equalsIgnoreCase(email))
    {
    pageContext.forward("form.jsp");
    session.setAttribute("LoggedIn", "true");
    }
    else
    {
    pageContext.forward("errorpage.jsp");
    }
    }




    con.close();
    %>
  2. #2
  3. Modding: Oracle MsSQL Firebird
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2001
    Location
    Outside US
    Posts
    8,527
    Rep Power
    538
    You can try something like:

    ResultSet rs = stmt.executeQuery("SELECT * FROM table");

    while (rs.next())
    {
    for(int col=1; col<=rs.getMetaData().getColumnCount();col++)
    System.out.print(rs.getString(col)+", ");
    System.out.println();
    }

IMN logo majestic logo threadwatch logo seochat tools logo