package entity;

import boundary.*;
import java.sql.*;

public class InvestorInfo {
	private static ResultSet investors = null;
	private static final String TABLE_NAME = "user";
	public static void fetchInvestorInfo() {
		String query = "SELECT * FROM " + TABLE_NAME;
		investors = DatabaseCommunicator.query(query);
	}
	public static void updateInvestorRank(int investor_id, int rank) {
		String query = "UPDATE " + TABLE_NAME + "SET RANK = " + rank + "WHERE user_id = " + investor_id;
		DatabaseCommunicator.query(query);
	}
	public static int getCurrentInvestorID() {
		int retval = -1;
		if (investors != null) {
			try {
				retval = investors.getInt("user_id");
			}
			catch (SQLException sqle) {
				System.err.println(sqle.toString());
			}
		}
		else {
			System.err.println("Error: Need to call fetchInvestorInfo() at least once.");
		}
		return retval;
	}
}
