Next Method for ResultSet ignoring the first result


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Next Method for ResultSet ignoring the first result

  1. #1
    MAK Guest

    Next Method for ResultSet ignoring the first result


    I have made a connection to an SQL database and executed a query returning
    a result set containing about 20 rows. However when I try to print the results
    the first record seems to be excluded. Some of my code is as follows :
    try
    {
    rs.next();
    h++;
    System.out.println(h);

    }

    final Object [][] data = new Object[h][5];

    Any suggestions would be welcome



  2. #2
    Paul Clapham Guest

    Re: Next Method for ResultSet ignoring the first result

    The error must be in some other part of your code, then. What you have
    posted is not enough to identify the problem.

    PC2

    "MAK" <majella.kavanagh@citicorp.com> wrote in message
    news:3c3d6b80$1@147.208.176.211...
    >
    > I have made a connection to an SQL database and executed a query returning
    > a result set containing about 20 rows. However when I try to print the

    results
    > the first record seems to be excluded. Some of my code is as follows :
    > try
    > {
    > rs.next();
    > h++;
    > System.out.println(h);
    >
    > }
    >
    > final Object [][] data = new Object[h][5];
    >
    > Any suggestions would be welcome
    >
    >




  3. #3
    Juliano Stringari Guest

    Re: Next Method for ResultSet ignoring the first result


    You forgot the loop "while", uderstood?

    int h=0;
    try {
    while (rs.next()) {
    h++;
    System.out.println(h);
    }
    }



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center