Wats wrong....?? can anyone help..

Hi Hi can anyone help?
i tried to extract the last row of item in the database by inserting a column call 'no' [in ascending order]....then extract out the one with the biggest value in 'no'. [effectively should be the last row of items]
however with the codes below.....it only allow me to extract out the first row of the data. .....how can i actually do in order to get the last row of data......PLEASE HELP ME!!
thank u
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:odbc:RMSdb");
java.sql.Statement statement = connection.createStatement();
java.sql.ResultSet res = statement.executeQuery("SELECT * FROM station9 " + "WHERE no = (SELECT MAX(no) AS maxno from station9)");
res.next();
          String app_power = res.getString("S");
          String voltage = res.getString("Voltage");
          String current = res.getString("Current");
          String real_pow = res.getString("P");
          String img_pow = res.getString("Q");
          String id = res.getString("no");
%>
<p align="center"><font face="Arial Black" size="4" color="#CC00CC">Voltage (r.m.s)
= </font><font face="Arial Black" size="4" color="#000000">  <%= voltage %>KV</font></p>
<p align="center"><font face="Arial Black" size="4" color="#CC00CC">Current (r.m.s)
=</font><font face="Arial Black" size="4" color="#000000">  <%= current %> KA</font></p>
<p align="center"><font face="Arial Black" size="4" color="#CC00CC">Apparent Power =</font><font color="#000000"><font face="Arial Black" size="4"> 
<%= app_power %>MVA</font></font></p>
<p align="center"><font face="Arial Black" size="4" color="#CC00CC">Active Power
=</font><font face="Arial Black" size="4" color="#000000">  <%= real_pow %> MW</font></p>
<p align="center"><font face="Arial Black" size="4" color="#CC00CC">Reactive Power =</font><font color="#000000"><font face="Arial Black" size="4"> 
<%= img_pow %>MVAR</font></font></p>

if ur question is getting the last row of a table then try this query instead
select * from emp where rowid in
(select rowid from emp where rownum<=(select count(*) from emp))
and rowid not in (select rowid from emp
where rownum<=(select (count(*)-1) from emp));
the above query will certainly return a single row and then u can if(rs.next()) and then extract the contents from the resultset....

Similar Messages

Maybe you are looking for