0

hello,

i want to cycle through a db table infinite times, ie; if there exists no value(reached end of table) in the result set, i wanna point the cursor to the start again...and it goes on infinite times
wat do i add and where

package project;
import java.io.*;
import java.net.*;
import java.lang.Object.*;
import java.sql.*;
import java.net.ServerSocket.*;
import java.lang.String.*;

public class db {

    public static void main(String a[]) throws ClassNotFoundException, SQLException
    {
        ResultSet resad;
         Connection connad;
         Statement statad;
      int i=0;
      String array[] = new String[10];

        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            connad = DriverManager.getConnection("jdbc:odbc:MS Access Database");
        statad = connad.createStatement();
        resad = statad.executeQuery("SELECT * FROM clients_online");
        while(true){




        try  
            {   

                        resad.next(); 

                        array[0]=resad.getString(1);//ip
                        if(resad.wasNull())
                        {
                            resad.first();
                        }
                        array[1]=resad.getString(2);//ma
                        array[2]=String.valueOf(resad.getInt(6));//adapt port
                        array[3]=resad.getString(7);//username
                        System.out.println("adaptport from db:"+array[2]);
                        System.out.println("ip from db:"+array[0]);
                        System.out.println("mac from db:"+array[1]);
                        System.out.println("username from db:"+array[3]);
             }
        catch(Exception x)
        {
//            resad.first();
            System.out.println(x);
            System.out.println("Unable to connect to database in laport");
        }



                        ++i;
                        System.out.println("RECORD:"+i);

        }
}
}

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by peter_budo
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.