Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_java thread: Why I can't get proper result by using getRow


Message #1 by Edward <zhangsc@n...> on Tue, 04 Jun 2002 09:09:31 +0800
Hi Khaled

1.	You have to use a ResultSet Navegable


2.	Go to the last() and take de getrow()


3.	If you need go to the first() at this.


See the example:
****************

This define a especial ResulSet you have use  JDBC 2.0


		Statement statement 
		    connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
					       ResultSet.CONCUR_READ_ONLY);


This method take a ResulSet as a parameter 


    ResultSetTableModel(ResultSet results) throws SQLException {

	this.results = results;                 // Save the results

	metadata = results.getMetaData();       // Get metadata on them

	numcols = metadata.getColumnCount();    // How many columns?

	results.last();                         // Move to last row

	numrows = results.getRow();             // How many rows?




   Julio Oliveira
Buenos Aires - Argentina
Java Developer - Instructor - Cursos @-Mail
-------------------------------------------
JOliveiraAR@y...
Oliveira_julio@y... 

***********************************************************************

-----Mensaje original-----
De: Khaled Ayoubi [mailto:javabk76@h...]
Enviado el: martes 4 de junio de 2002 13:50
Para: Professional Java
Asunto: [pro_java] RE: Why I can't get proper result by using getRow


Just as explanation:
getRaw() return the number of current raw in the ResultSet, not the number 
of raws in the ResultSet.

Java BK

> Hi Edward

First you has to move to last()


   Julio Oliveira
Buenos Aires - Argentina
Java Developer - Instructor - Cursos @-Mail
-------------------------------------------
JOliveiraAR@y...
Oliveira_julio@y...

***********************************************************************

-----Mensaje original-----
De: Edward [mailto:zhangsc@n...]
Enviado el: lunes 3 de junio de 2002 22:10
Para: Professional Java
Asunto: [pro_java] Why I can't get proper result by using getRow


Hello,
In Oracle8i,I use SQL statement to search:

SQL> select system_id,syori_kubun from user_menu_tbl where user_id='Mary';

I got two Record:

SYST SY
---- --
12   1
69   1

Then I use Java to do same work:
   ...
   stmt.executeQuery("select system_id,syori_kubun from user_menu_tbl where
user_id='Mary'");
   ResultSet rs=stmt.getResultSet();
   System.out.println(rs.getRow());

I think rs.getRow should return 2 because I have two record,but I got 
0.Why?
Thanks!
Edward



  Return to Index