1
2
3
4
5
6 package com.rc.celeritas.db;
7
8 import com.rc.celeritas.exception.CeleritasException;
9 import java.sql.Connection;
10 import java.sql.ResultSet;
11 import java.sql.Statement;
12 import java.util.ArrayList;
13 import org.apache.log4j.Logger;
14
15
16
17
18
19 public class GenericDAO {
20
21 private static Logger log = Logger.getLogger(GenericDAO.class);
22
23
24
25
26
27
28
29
30 public static ArrayList<String> getSingleColumnList(Connection conn, String sql) throws CeleritasException{
31 ArrayList<String> singleColumnList = null;
32 try{
33 Statement stmt = conn.createStatement();
34 ResultSet rs = stmt.executeQuery(sql);
35 if(rs != null){
36 singleColumnList = new ArrayList<String>();
37 while(rs.next()){
38 singleColumnList.add(rs.getString(1));
39 }
40 }
41 } catch (Exception e){
42 log.error("Error in generating Single Coulmn List : " + e.toString());
43 throw new CeleritasException(e);
44 } finally {
45 DBHelper.closeConnection(conn);
46 }
47 return singleColumnList;
48 }
49
50 }