Search in sources :

Example 11 with ProjectBean

use of models.ProjectBean in project bil372-proje by mertserezli.

the class SearchDAO method searchForProjectDescription.

public static List<ProjectBean> searchForProjectDescription(String descriptionRequest) throws SQLException {
    List<ProjectBean> result = new ArrayList<ProjectBean>();
    PreparedStatement ps = null;
    String searchQuery = "Select DISTINCT * From PROJECT Where UPPER(Description) LIKE UPPER('%" + descriptionRequest + "%')";
    try {
        ConnectionManager connect = new ConnectionManager();
        currentConnection = connect.getConnection();
        ps = currentConnection.prepareStatement(searchQuery);
        rs = ps.executeQuery();
        while (rs.next()) {
            ProjectBean project = new ProjectBean();
            project.setTitle(rs.getString("Title"));
            project.setDescription(rs.getString("Description"));
            project.setPid(rs.getInt("Pid"));
            project.setState(rs.getString("State"));
            project.setVotenum(rs.getInt("Votenum"));
            project.setCreation_Date(rs.getDate("Creation_Date"));
            result.add(project);
        }
    } finally {
        finalizeConnection(currentConnection, ps, rs);
    }
    return result;
}
Also used : ProjectBean(models.ProjectBean) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement)

Aggregations

ProjectBean (models.ProjectBean)11 ArrayList (java.util.ArrayList)6 UserBean (models.UserBean)5 PrintWriter (java.io.PrintWriter)4 PreparedStatement (java.sql.PreparedStatement)3 ServletException (javax.servlet.ServletException)3 NotificationBean (models.NotificationBean)3 IOException (java.io.IOException)1 Date (java.sql.Date)1 SQLException (java.sql.SQLException)1 List (java.util.List)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 ServletContext (javax.servlet.ServletContext)1 CommentBean (models.CommentBean)1 CompanyBean (models.CompanyBean)1