Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/sbugs/dao/attributes/PriorityDAO.java


1   /*
2    * This program is free software; you can redistribute it and/or
3    * modify it under the terms of the GNU General Public License
4    * as published by the Free Software Foundation;  version 2 only.
5     *
6    * This program is distributed in the hope that it will be useful,
7    * but WITHOUT ANY WARRANTY; without even the implied warranty of
8    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9    * GNU General Public License for more details.
10   *
11   * You should have received a copy of the GNU General Public License
12   * along with this program; if not, write to the Free Software
13   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
14   */
15  package org.sbugs.dao.attributes;
16  
17  import java.util.*;
18  import java.sql.*;
19  
20  import org.sbugs.dao.DAO;
21  import org.sbugs.model.attributes.Priority;
22  
23  public class PriorityDAO extends DAO
24  {
25    private static PriorityDAO instance = new PriorityDAO();
26    
27    protected PriorityDAO() {}
28    
29    public static PriorityDAO getInstance() { return instance; }
30    
31    public List loadAllPriorities( Connection connection ) throws SQLException
32    {
33      String sql = "select priority_id, priority_name from priority order by priority_id";
34      
35      PreparedStatement statement = null;
36      try
37      {
38        statement = connection.prepareStatement( sql );
39        ResultSet results = statement.executeQuery();
40        ArrayList list = new ArrayList();
41        while( results.next() )
42        {
43          list.add( new Priority( results.getInt( "priority_id" ),
44                      results.getString( "priority_name" ) ) );
45        }
46        return list;
47      }
48      finally
49      {
50        closeStatement( statement );
51      }
52    }
53  }