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);

        }
}
}

If you do infinitive loop you crash. What is purpose of this exercise?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.