Click here to Skip to main content
15,037,009 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to get(retrieve) mysql databse data to java array list and print one by one using indexes...
I already tried normal do-while for retrieve, but i need to take values to array list...

What I have tried:

public class Portdetails 
    public static void main(String[] args) {
                    try ( Connection cn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/airportinfo","root",""))
                        Statement smt=(Statement) cn.createStatement();
                        //query to display all records from table employee
                        String q="SELECT * FROM airportinfo";
                        //to execute query
                        ResultSet rs=smt.executeQuery(q);
                        //to print the resultset on console
                            System.out.println("Record Not Found...");
		catch(Exception e)
Updated 2-Oct-19 20:28pm
ZurdoDev 15-Sep-19 20:53pm
What is the question?
James.Read(JR) 15-Sep-19 20:57pm
I need to retrieve mysql database data to array list and pass them to adjacency list by using index..
Maciej Los 3-Oct-19 3:24am
Use "Reply" widget to be sure that notification system will inform the user about your reply.
Where to find that widget? On the right side of nick/login.
Richard MacCutchan 3-Oct-19 4:05am
Instead of using System.out.println for each record, add the items to your array list.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900