
/* Genomic Comparison Tool
   Master Thesis of computer science

   Author: Yue Lu
   Version: 1.1

*/


/* This class get the connection with database and get the all
	the column name from the table
*/

import java.net.*;
import java.sql.*;
import java.io.*;
import java.util.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;

public class DatabaseColumnName
{
	//constructor
    public DatabaseColumnName(String query)
    {

	  try
      {
		//get the database connection instance
		DatabaseConnection connection=DatabaseConnection.getInstance();

		 con=connection.getConnection();
		 //execute the query
         Statement stmt = con.createStatement();
	     ResultSet rs = stmt.executeQuery(query);

	     //get the query's columnNames
		 ResultSetMetaData rsmd=rs.getMetaData();
		 for(int i=1; i<=rsmd.getColumnCount(); i++)
		 	ColumnName.addElement(rsmd.getColumnLabel(i));

		 stmt.close();
		 //rs.close();
      }

      catch (SQLException ex)
      {
		  System.out.println ("3"+ex);
      }
   }

	// return the columnName
	public Vector getColumnName()
	{
		return ColumnName;
	}

	private Connection con;
	private String query;
	private Vector ColumnName=new Vector(0,1);
}
