2

How to retrieve the mysql database value into array using java.If I retrieve Student Name from mysql Database means How can I get The all Student name in a mysql table to array using java?give me some examples.

thanks in advance

1
  • Since you'd retrieve DB results into an array the exact same way in the command line or a servlet as in Swing, we can conclude this problem has nothing to do with Swing. Commented Jan 5, 2012 at 6:13

2 Answers 2

4

Use ArrayList<T> to store name from database and later you may convert it to String[] using List.toArray() method.

ArrayList<String> list= new ArrayList<String>();
while (rs.next()) {
    list.add(rs.getString(1));
}   
Sign up to request clarification or add additional context in comments.

Comments

0

I'm not sure if this is right question on SO, it seems you've not tried anything :(

Btw, have a look at this first : JDBC Basics

First query all the student names from DB, then

 while(resultset.next(){
            //add each of them to array
       }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.