Thread: problem in resultset relative method

problem in resultset relative method

From
arun vc
Date:
hello

i have found some problem in using the relative()
method of ResultSet

the problem occured when i upgrade my old
postgres.jar driver with the new one posted on ur site
http://jdbc.postgresql.org/download/pgjdbc2.jar

try exicte this program using both drivers
and u will find the difference

import java.sql.*;

public class sqlDriverTest
{
    String Driver = "org.postgresql.Driver";
    String Bridge="jdbc:postgresql://localhost/database";
    String LoginName="postgres";
    String Password="postgres";

     try
     {

           Class.forName(Driver);
           Connection con=
DriverManager.getConnection(Bridge,LoginName,Password);
        System.out.println("Connection made: " + con);

        PreparedStatement pm=con.prepareStatement("SELECT *
FROM admin");
        ResultSet rs=pm.executeQuery();

        rs.last();
        int tot=rs.getRow();    //my tot returned 10 records

        rs.beforeFirst();

        int kk=1;

        while(kk<=tot)        //the program stoped after reading 3
records and rest of the 7 records are shown wrongly
        {
            rs.relative(kk);
            System.out.println(rsProj.getString(1));
            kk=kk+1;
        }


       }
     catch(Exception e)
     {
         System.out.println("Error "+e.getMessage());
     }

    }

        //the program stoped after reading first 3 records
and rest of the 7 records are shown wrongly
        //why iam getting error in using relative() method
this problem was not in the previous postgres.jar
driver

        please look in to this problem

=====
The Future belongs to those who believe in the beauty of their dreams...............................................
Arun VC, E Team India Web Solutions,
Serene,Anupama Nagar,Pongummoodu,Trivandrum
Phone : +91 471 558089. Fax   : +91 471 551807.
http://www.e-teamindia.com
http://www.geocities.com/vcarun

__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

Re: problem in resultset relative method

From
Dave Cramer
Date:
Arun,

The problem must have been with the previous code, because this is doing
what it should be doing.

Here are the results of my run

Row 1Value -->1
Row 2Value -->3
Row 3Value -->6
Row 4Value -->10
Row 5Value -->10
Row 6Value -->10
Row 7Value -->10
Row 8Value -->10
Row 9Value -->10
Row 10Value -->10


the first one get's row 1 and increments kk to 2 which moves relative to
the third row, and then increments kk to 3 which moves relative to row
3, and then increments kk to 4 which moves relative to row 10

Dave

On Fri, 2002-05-03 at 03:49, arun vc wrote:
> hello
>
> i have found some problem in using the relative()
> method of ResultSet
>
> the problem occured when i upgrade my old
> postgres.jar driver with the new one posted on ur site
> http://jdbc.postgresql.org/download/pgjdbc2.jar
>
> try exicte this program using both drivers
> and u will find the difference
>
> import java.sql.*;
>
> public class sqlDriverTest
> {
>     String Driver = "org.postgresql.Driver";
>     String Bridge="jdbc:postgresql://localhost/database";
>     String LoginName="postgres";
>     String Password="postgres";
>
>      try
>      {
>
>            Class.forName(Driver);
>            Connection con=
> DriverManager.getConnection(Bridge,LoginName,Password);
>         System.out.println("Connection made: " + con);
>
>         PreparedStatement pm=con.prepareStatement("SELECT *
> FROM admin");
>         ResultSet rs=pm.executeQuery();
>
>         rs.last();
>         int tot=rs.getRow();    //my tot returned 10 records
>
>         rs.beforeFirst();
>
>         int kk=1;
>
>         while(kk<=tot)        //the program stoped after reading 3
> records and rest of the 7 records are shown wrongly
>         {
>             rs.relative(kk);
>             System.out.println(rsProj.getString(1));
>             kk=kk+1;
>         }
>
>
>        }
>      catch(Exception e)
>      {
>          System.out.println("Error "+e.getMessage());
>      }
>
>     }
>
>         //the program stoped after reading first 3 records
> and rest of the 7 records are shown wrongly
>         //why iam getting error in using relative() method
> this problem was not in the previous postgres.jar
> driver
>
>         please look in to this problem
>
> =====
> The Future belongs to those who believe in the beauty of their dreams...............................................
> Arun VC, E Team India Web Solutions,
> Serene,Anupama Nagar,Pongummoodu,Trivandrum
> Phone: +91 471 558089. Fax   : +91 471 551807.
> http://www.e-teamindia.com
> http://www.geocities.com/vcarun
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - your guide to health and wellness
> http://health.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
>