as I read in javadoc resultset represents a table which contain
database therefore I want to know if there are a general way to iterate this result set and return data of it.
on other side the interface result set contain method getString(int coloumindex), how can I implement this method?

Recommended Answers

All 7 Replies

By reading the tutorials.

I'm already reading this tutorial but this tutorial doesn't contain any implementation for interface Resultset.

Are you writing a JDBC driver? If not, they you don't need to implement that interface. You use it to work with the results returned from a query.

yes, I'm implementing a JDBC driver and still having the same problem

Then you can implement it however you choose as long as it conforms to the documented behavior of the interface.

If you do not understand interface implementation, I don't see how you are going to be able to write your own JDBC driver.

Are you sure you aren't confusing "implementing an interface" with "using an interface"?

yes, I mean the difference .

for example if I want to implement method getString(int coloumindex) therefore I want to iterate on result set and choose the specific element in specific given no of coloum .I will implement that by declaring string[][] in class result set and then to find the value of any coloum, I will make a for loop on string[][].
but I think that that algorithm is not efficient because I declared a variable in class resultSet. so if any body having other algorithm tell me.

getString() returns the value of the column in the current row of the result set. This means that you already have a reference to the row or its location, so it is simply a matter of returning the value of the column as a String. Your iteration or access methods will need to maintain that reference to the current row.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.