
/* Genomic Comparison Tool
   Master Thesis of computer science

   Author: Yue Lu
   Version: 1.1

*/


/* this class get database connection instance and
	get row number of the resultset
*/

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

public class DatabaseRowNumber
{
	//constructor
	public DatabaseRowNumber(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);

				//count the row number
			 while(rs.next())
			 	m++;

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

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

	      }

	   }

	//return the row number
	  public int getRowNumber()
	 {
		return m;
	 }

	private Connection con;
	private int m=0;

}