More features for Android app access to device installation, etc.
[iot2.git] / iotjava / iotinstaller / Table.java
index c3fa5ab1811ef154f0ac60da707a8c8b6271e9d5..3b292b7ea21f6698aaf113be9f8f68ea4f770229 100644 (file)
@@ -9,6 +9,7 @@ import java.io.*;
 import java.sql.*;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Scanner;
 import java.util.Properties;
 
@@ -324,6 +325,34 @@ public class Table {
 
                return arrTbl;
        }
+       
+       /**
+        * A method to get the column names of a specified table
+        *
+        * @return HashSet<String> : holds all column information for specific tables
+        * @author Kevin Truong<kctruon1@uci.edu>
+        */
+       public HashSet<String> getColumnNames(){
+               int iCols = getGeneralNumOfCols();
+               String[] arrTbleColNames = new String[iCols];
+               HashSet<String> arrTblColNames = new HashSet<String>();
+               try{
+                       rs.beforeFirst();
+                       rsmd = rs.getMetaData();
+                       while(rs.next()){
+                               for(int i = 0;i < iCols; i++){
+                                       arrTblColNames.add(rsmd.getColumnName(i+1));
+                               }
+                       }
+                       rs.beforeFirst();
+               } catch (SQLException ex){
+                       System.out.println("Table: Exception: ");
+                       ex.printStackTrace();   
+               }
+
+               return arrTblColNames;
+       }
+
 
        /**
         * A method to close statement manually