1 package org.ashkelon; 2 3 import java.sql.Connection ; 4 import java.sql.ResultSet ; 5 import java.sql.SQLException ; 6 import java.sql.Statement ; 7 import java.util.ArrayList ; 8 import java.util.List ; 9 10 13 public class Generic 14 { 15 public static List listNames(Connection conn, String tablename) throws SQLException 16 { 17 String sql = "select name from " + tablename + " order by name"; 18 Statement stmt = conn.createStatement(); 19 ResultSet rset = stmt.executeQuery(sql); 20 List pkgs = new ArrayList (); 21 while (rset.next()) 22 { 23 pkgs.add(rset.getString(1)); 24 } 25 rset.close(); 26 stmt.close(); 27 return pkgs; 28 } 29 } 30 | Popular Tags |