1 2 3 package com.espada.bugtracker.app; 4 5 import java.io.*; 7 import java.sql.*; 8 import java.util.*; 9 10 import com.espada.bugtracker.persistence.*; 12 13 import com.espada.bugtracker.app.*; 15 16 23 24 public class Status 25 { 26 public int statusID; 27 28 public String status; 29 30 public boolean def; 31 32 public Status() 33 { 34 35 37 } 39 40 public Status (int id) 41 { 42 43 try 44 { 45 46 Connection d = DatabaseConnectionPool.getConnection(); 47 Statement st = d.createStatement(); 48 ResultSet rs = st.executeQuery("select * from status where status_id=" + id); 49 50 while (rs.next()) 51 { 52 53 statusID = id; 54 55 status = rs.getString(1); 56 57 def = rs.getInt(2) == 1; 58 59 } 60 61 st.close(); 62 DatabaseConnectionPool.freeConnection(d); 63 64 } 65 66 catch (Exception E) 67 { 68 69 71 } 72 } 74 75 public String getName() 76 { 77 78 return status; 79 80 } 82 83 public int getID() 84 { 85 86 return statusID; 87 88 } 90 91 public boolean isDefault() 92 { 93 94 return def; 95 96 } 98 99 102 public static Vector getStatusList(boolean getDefaults) 103 { 104 105 Vector v = new Vector(); 106 107 try 108 { 109 110 Connection d = DatabaseConnectionPool.getConnection(); 111 Statement st = d.createStatement(); 112 String SQL = new String (); 113 114 if( getDefaults ) 115 { 116 SQL = "select status_id from status where def=1 order by status"; 117 } 118 else 119 { 120 SQL = "select status_id from status where def=0 order by status"; 121 } 122 123 ResultSet rs = st.executeQuery(SQL); 124 125 while (rs.next()) 126 { 127 128 v.add( new Status( rs.getInt( 1 ) ) ); 129 130 } 131 132 st.close(); 133 DatabaseConnectionPool.freeConnection(d); 134 return v; 135 } 136 137 catch (Exception E) 138 { 139 E.printStackTrace(); 140 v.add( new String ("Error") ); 141 v.add( E.getMessage() ); 142 return v; 143 } 144 145 } 147 148 149 150 public static Vector getStatusList() 151 { 152 153 Vector v = new Vector(); 154 155 try 156 { 157 158 Connection d = DatabaseConnectionPool.getConnection(); 159 Statement st = d.createStatement(); 160 String SQL = new String (); 161 162 ResultSet rs = st.executeQuery("select status_id from status order by status"); 163 164 while (rs.next()) 165 { 166 167 v.add( new Status( rs.getInt( 1 ) ) ); 168 169 } 170 171 st.close(); 172 DatabaseConnectionPool.freeConnection(d); 173 return v; 174 } 175 176 catch (Exception E) 177 { 178 E.printStackTrace(); 179 v.add( new String ("Error") ); 180 v.add( E.getMessage() ); 181 return v; 182 } 183 184 } 186 187 188 189 } | Popular Tags |