Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning last row

Status
Not open for further replies.

Plogu101

Programmer
Nov 5, 2004
12
GB
I know this is FAQ but I can't seem to get this to work. I need to return the last row in the table, I'm using auto_increment which is the 'priKey' column. 'beachName' is the name of the table , 'DATEOFFILE' is the column in the table that I need to return the last value for. The println outputs

Code:
 'DBconnect test date :::: com.mysql.jdbc.ResultSet@32fb4f'

I've tried a varity of approaches using 'rs.getString(String ColumnName);' while selecting the whole row, but then I get an SQL error 'Error before start of results set' ?

Code:
Rating atrdo = (Rating) rateingList.get(ratingCounter);
            dateOfFile = atrdo.getDateOfFile();
            beachName = atrdo.getBeachName();
         
            ResultSet rs = statement.executeQuery("SELECT `DATEOFFILE` FROM `" + beachName + "` ORDER BY `priKey` DESC LIMIT 1");
            String testDateT = rs.toString();
            System.out.println("DBconnect test date ::::  " + testDateT);
            
                if (testDateT.equals(dateOfFile))
                {
                    System.out.println(" File has already been downloaded today ");  
                    statement.close();
                    connection.close();
                }

If anyone can help it would be greatly appreciated.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top