Information regarding ResultSet !

Hi every one!

Can anyone tell me what kind of output does a ResultSet object hold?And can we store this in any other object?

Also as i know the output of an sql query will be stored in ResultSet object.And we use rs.next() to move through these select records.

But my doubt is.,

while(rs.next())

{

String dis = rs.getString(3);

out.println("<tr>");

out.println("<td>");

out.println(rs.getInt(1));

out.println("</td>");

out.println("<td>");

out.println(rs.getString(2));

out.println("</td>");

out.println("<td>");

out.println("<a href=http://localhost:8080/servlets-examples/detail?name=dis>");

out.println(rs.getString(3));

out.println("</a>");

out.println("</td>");

out.println("<td>");

out.println("<a href=http://localhost:8080/servlets-examples/addetail>");

out.println(rs.getString(4));

out.println("</a>");

out.println("</td>");

out.println("</tr>");

is it correct to use String dis =rs.getString(3) and then further down use rs.getInt(1)?

Also is it that we can use rs.setXXX() only once per field?Plz giude me!

[1684 byte] By [me_n_javaa] at [2007-11-26 18:04:06]
# 1

> Can anyone tell me what kind of output does a

> ResultSet object hold?And can we store this in any

> other object?

The ResultSet represents a communication with the database to obtain the results in question. Don't store it in other objects - use it as briefly as reasonably possible, then close it to free up resources.

The data obtained from the ResultSet can be stored wherever you want though.

> is it correct to use String dis =rs.getString(3) and

> then further down use rs.getInt(1)?

No. Obtain in order once only. It may or may not work depending on the driver if you do it otherwise.

> Also is it that we can use rs.setXXX() only once per

> field?Plz giude me!

You can use it multiple times per field, but it's completely pointless as each call will overwrite the value that you set previously.

dcmintera at 2007-7-9 5:34:25 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Thankz a lot for the information!
me_n_javaa at 2007-7-9 5:34:25 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...