import java.sql.*;
import java.util.Map;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Scanner;
import java.util.Properties;
*/
public boolean isTableEmpty() {
- if (rs == null) {
- return true;
+ // Check if this table has any entries
+ String strCommand = "SELECT * FROM " + strTableName;
+ rs = sqlInterface.sqlCommandQuery(strCommand);
+ try {
+ if (!rs.first()) {
+ return true;
+ }
+ } catch(SQLException ex) {
+ System.out.println("Table: Exception: ");
+ ex.printStackTrace();
}
return false;
-
}
/**
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