Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC Arraylist from row values
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Josh Kumar
Arraylist from row values
1 Answer(s)      3 years and 2 months ago
Posted in : JDBC


Hello,

can anyone please help on how to make an arraylist from the row values of a particular column from a database table?

Thanks in advance!


Advertisement
View Answers

August 4, 2011 at 11:56 AM


import java.sql.*;
import java.util.ArrayList;
class  Retrieve{
public static void main(String[] args){
    try{
           Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from employee");

           ArrayList<String> list=new ArrayList<String>();
             while(rs.next()){
             list.add(rs.getString("name"));
              }
           for(int i=0;i<list.size();i++){
           System.out.println(list.get(i).toString());
           }
    }
    catch(Exception e){
    System.out.println(e);
    }

    }
}


Related Tutorials/Questions & Answers:
Arraylist from row values
Arraylist from row values  Hello, can anyone please help on how to make an arraylist from the row values of a particular column from a database...("select * from employee"); ArrayList<String> list=new ArrayList<
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file containing a method which is returning an ArrayList. I want to display the records
Advertisements
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file containing a method which is returning an ArrayList. I want to display the records
Radio button with values from a String ArrayList in JSP?
Radio button with values from a String ArrayList in JSP?  Radio button values in JSP ArrayList<String> cs = CourseAssignments.getInstance...;/form> <%} In ArrayList cs I have all the courses
How to update table column from the values of Arraylist in java
How to update table column from the values of Arraylist in java  Hii Sir, I have an arraylist containing these values [2, 1, 1, 1, 1, 1, 1... As per my need i have to add these values into different fields of single
JTable duplicate values in row
JTable duplicate values in row  JTable duplicate values in row
Remove duplicates from ArrayList
Remove duplicates from ArrayList Sometimes we added large amount of data to ArrayList  where some values will get added twice or thrice which may... the Set back to the ArrayList. Here is the code: import java.util.*; public
Want to display Arraylist items on same row in JSF
Want to display Arraylist items on same row in JSF  I want do display values of one arraylist on same row using datatable? If i use h:column, then it goes on different row. Please tell me, how I can do it?   Hi Friend
Updating rows who has same id with different values for each row from java program
Updating rows who has same id with different values for each row from java... to update the records which contains sid 1. But i have to update first row (having sid 1) with "naveen" as value for sname column.And second row(having sid 1
set the arraylist values - Struts
set the arraylist values   ResourceIdleReport.jsp <
dispalying arraylist values in table form
dispalying arraylist values in table form  My result is in arraylist and i want to display it in table form using iterator tag
How to read and retrieve jtable row values into jtextfield on clicking at particular row ...
How to read and retrieve jtable row values into jtextfield on clicking at particular row ...  Hello Sir, I am developing a desktop... to read all the values of particular row at which mouse is clicked. and display
delete row from a table in hibernate
delete row from a table in hibernate  is there method to delete row in a table using hibernate like save(-) to insert row
Delete a row from database by id
Delete a row from database by id  I m creating a small application... all the values are added in to database and page is redirected to a new page...) for "DELETE" AND "UPDATE". On clicking delete which is hyper link that particular row
display the hidden text from that row, when onclick on a row of 1- 10
display the hidden text from that row, when onclick on a row of 1- 10  Using JSP: I'm displaying a set of values from the databse in a table rows (1 to 10)in jsp page, when onclick on one of the view row, it has to submit
Query to insert values in the empty fields in the last row of a table in Mysql database?
Query to insert values in the empty fields in the last row of a table in Mysql... row of my MYSQL database. Now I want to fill up those empty fields in the last row. So what will be the query
Remove checked checkboxes from arraylist and dipaly remaining arraylist
Remove checked checkboxes from arraylist and dipaly remaining arraylist ... facing proble in deleting them from arraylist and display arrylist. Please... to replace previous arraylist with new arraylist (which do not contain deleted
Removing a Row from a JTable
Removing a Row from a JTable     ... to remove any one row's data that is wrong entry then you must have to remove from the JTable. For removing the data of row from JTable, you will remove it from
ArrayList from JSP to Servlet - JSP-Servlet
ArrayList from JSP to Servlet  Hi, I have an arraylist declared in a scriplet in a jsp page. how can i access the arraylist in a servlet which...;String> am = new Arraylist(); Arraylist pm = new Arraylist
How to delete the row from the Database by using servlet
How to delete the row from the Database by using servlet  Dear Sir...: Delete row from database using servlet   In that link solution... then the user data to be delete from the database table. Assume in Database table have
reading a csv file from a particular row
reading a csv file from a particular row  how to read a csv file from a particular row and storing data to sql server by using jsp servlet
How to pass an arraylist from servlet to jsp?
How to pass an arraylist from servlet to jsp?  Hello, Can anyone please tell me how to pass an arraylist from servlet to jsp? I have two arraylist one of type String and the other int. How to send both the arraylists from
delete row from a table using hibernate
delete row from a table using hibernate  //code in java file String hql="delete from CONTACT c where ID=6"; Query query=session.createQuery... [delete from CONTACT] int i=query.executeUpdate
Check duplicate values and the count in an arraylist and store it in another list
Check duplicate values and the count in an arraylist and store it in another list  Hi All, I have a list which has four fields: year name, month... and the total of search string in that month and put that values in a new list. Please help
How to retrieve single row from MSSQL
How to retrieve single row from MSSQL  Hello sir, Sir i had created the table in MSSQL,the fields with patient name,pid,Dname(doctor name... mean only his row has to be displayed in the next Jpanel within same window.I
How to retrieve single row from MSSQL
How to retrieve single row from MSSQL  Hello sir, Sir i had created the table in MSSQL,the fields with patient name,pid,Dname(doctor name... mean only his row has to be displayed in the next Jpanel within same window.I
How to retrieve single row from MSSQL
How to retrieve single row from MSSQL  Hello sir, Sir i had created the table in MSSQL,the fields with patient name,pid,Dname(doctor name... mean only his row has to be displayed in the next Jpanel within same window.I
Pick Prime Numbers from the ArrayList
integer values in the arraylist and from the arraylist we have to find the prime...Pick Prime Numbers from the ArrayList Programmers mostly used ArrayList... isPrime; } public static void main(String[] args) { ArrayList list = new
how to display the selected row from the data table in model panel ??
how to display the selected row from the data table in model panel ?? ... class TableRecordBean { private ArrayList <TableData> dataList; private ArrayList <TableData> selectList; public void assignDataList() { dataList
Find max and min value from Arraylist
Find max and min value from Arraylist In this tutorial, you will learn how to find the maximum and minimum value element from the ArrayList. Java provides... the largest and smallest values from the list. Example: import java.util.
Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database
Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database  Hi members, I have one Html table in jsp page and i am iterating values (in columns of html table)from
 

 

 

DMCA.com