Jump to content

ResultSet in JDBC

- - - - -

  • Please log in to reply
3 replies to this topic

#1
eman ahmed

eman ahmed

    Learning Programmer

  • Members
  • PipPipPip
  • 79 posts
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?

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
Ehm, you normally don't implement that yourself but just use the implementation that is supplied.
If you use SQL in java. You execute a statement, and it returns a ResultSet. Every method there has code inside it. It should allready work.

#3
eman ahmed

eman ahmed

    Learning Programmer

  • Members
  • PipPipPip
  • 79 posts
I meant how can I implement methods in class resultset .and what's the difference between resultset and resulsetmetaData.

#4
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
If you, for whateve reason, want to make your own ResultSet class you just need your class to implement the ReseltSet interface.

public class Myclass implements ResultSet{


//Every method of the ResultSet interface must be coded here<<

}


somewhere else:

ResultSet mySet = new MyClass();


In a Database you got the data and the metadata.
Metadata is data about the data. So the resultset contains what's inside the table, the metadata contains info about the layout of the table like number of columns etc.

Take a simple .txt file as an example. The text itself would be the data, the stuff that windows adds: created by, date, size of the file, name,... all this would be metadata.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users