package utility;
import java.sql.*;
import java.util.Vector;

public class ResultSelect
{
	public Vector columnVector = new Vector();
	public Vector rowVector = new Vector();
	int rowsReturned = 0;
	int columnsReturned = 0;

	public ResultSelect (ResultSet rs)
	{

		try
		{
			ResultSetMetaData metaData = rs.getMetaData();
			columnsReturned = metaData.getColumnCount();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}

		Vector cv[] = new Vector[columnsReturned];

		for (int i=0; i < columnsReturned; ++i)
			cv[i] = new Vector();

		int count = 0;
		try
		{

			while (rs.next())
			{
				count++;
				for (int i=0; i < columnsReturned; ++i)
				{
					cv[i].addElement(rs.getString(i+1));
				}
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}

		rowsReturned =  count;//cv[0].size();
		for ( int i = 0 ; i< columnsReturned ; ++i)
			columnVector.addElement(cv[i]);

		Vector rv[] = new Vector[rowsReturned];
		for (int i=0;i<rowsReturned;++i)
		{
			rv[i]=new Vector();
			for (int j=0;j<columnsReturned;++j)
			{
				 rv[i].addElement(cv[j].elementAt(i));
			}
			rowVector.addElement(rv[i]);
		}
	}
	public Vector getRowVector()
	{
		return rowVector;
	}
	public Vector getColumnVector()
	{
		return columnVector;
	}
}
