
/* Genomic Comparison Tool
   Master Thesis of computer science

   Author: Yue Lu
   Version: 1.1

*/


/* this class get database connection instance and
	get the resultset as a list
*/
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 DatabaseQueryString
{
	public DatabaseQueryString(String query)
    {
	  try
      {

		// get the database connection instance
		 DatabaseConnection connection=DatabaseConnection.getInstance();
		 con=connection.getConnection();

		 //execute the query
		 if(query!=null){
         Statement stmt = con.createStatement();
	     ResultSet rs = stmt.executeQuery(query);

	     //add the ResultSet to the vector
		 list.removeAllElements();
		 while(rs.next())
		      list.addElement(rs.getObject(1));
		 stmt.close();
		 //rs.close();
      }
  }
      catch (SQLException ex)
      {

		  System.out.println ("6"+ex);
      }

   }

	// return the query as a Vector
	public Vector getList()
	{
		return list;
	}


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