ResultSet question

Hi Developers,

I have a question about copying of a resultset object into another ResultSet object. To make it much clear of what I am trying to do, I am retreiving a particular row by using absolute(int) method in a given Scrollable ResultSet object(rs1).Now I want to store somehow the values of that particular row only in a ResultSet object only(either rs1 or in a different one).For this, I was trying to use another Scrollable ResultSet object(rs2) and copy the contents(just 1 one row) in the manner(rs2=rs1).The main reason that I am trying to store them in a ResultSet object is beacuse I have a helper package which takes that particular ResultSet object and displays it. I am having trouble copying in this manner.Could anyone please suggest me a method for doing this or let me know of where exactly I was going wrong?

Thanking you,

Ashwin

[890 byte] By [AshwinT] at [2007-9-26 7:07:15]
# 1

It would be extremely difficult for you to create a ResultSet object, because ResultSet is an interface that would require you to define over 100 methods. The only practical method for getting a ResultSet is to ask the driver to give you one; the programmers of the driver have already done all that hard work defining a ResultSet implementation. And the only way to get a ResultSet from a JDBC driver is to use Statement (or PreparedStatement or CallableStatement) and call its executeQuery() method. In other words, have the driver execute the query that returns the results you need.

On second thought, why do you need another ResultSet object? Why can't you just give rs1 to your helper package?

DrClap at 2007-7-1 16:47:49 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

Well, here is one way to do it.

Once you have found the record you want, get the primary key / value of that row and execute a new query with a where clause that includes primary key values, this would return the row that you were looking for. ResultSet from that query is what you then pass on to your helper class.

Of course, like DrClap said, you can pass the same resultset but I sense that your helper package requires resultset to have only one record and you probably dont want to change the implementation of your helper class.

ashutosh at 2007-7-1 16:47:49 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...