package roseindia;

import java.sql.*;
import java.util.*;
import java.io.*;

public class TableBean {
    Connection con ;
    Statement ps;
    ResultSet rs;
    private List perInfoAll = new ArrayList();

    public void setPerInfoAll(List perInfoAll) {
        this.perInfoAll = perInfoAll;
    }
    
    public List getPerInfoAll() {
        int i = 0;
        try{
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
            ps = con.createStatement();
            rs = ps.executeQuery("select name from emp");
            while(rs.next()){
                perInfoAll.add(i,new tableData(rs.getString("name")));
                i++;
            }            
        } catch (Exception e) {
            System.out.println("Error Data : " + e.getMessage());
        } 
        return perInfoAll;
    }
    
    public class tableData {
        private String name;
        
        public tableData(String name) {
            this.name = name;
        }            

        public void setName(String name) {
            this.name = name;
        }
                
        public String getName() {
            System.out.println("Name: "+name);
            return name;
        }
    }
}
