package org.maskat.demo.petstore;
import java.sql.*;
import java.util.*;

public class ProductDAO {

	private Connection con = null;
	
	public ProductDAO(Connection con){
		this.con = con;
	}
	
	public Vector findProduct(String ProductId) throws SQLException{
	
		Vector ret = null;
		String sql = null;
		ResultSet rs = null;
		
		try{
			sql = "select * from product where ProductID like '"+ProductId+"%'";
			PreparedStatement stmt = null;
			stmt = con.prepareStatement(sql);
			rs = stmt.executeQuery();
			ret = new Vector();
			
			while(rs.next()){
				Product obj= new Product(rs.getString("ProductID"), rs.getString("Name"));
				ret.addElement(obj);
			}
			
			rs.close();
			
		}catch(Exception e){
		      e.printStackTrace();
		}
		
		return ret;
			
	}
}