| 1 2 package com.espada.bugtracker.app; 3 4 import java.io.*; 6 import java.sql.*; 7 import java.util.*; 8 9 import com.espada.bugtracker.persistence.*; 11 12 import com.espada.bugtracker.app.*; 14 15 22 23 public class Severity 24 { 25 26 public int severityID; 27 28 public String severity; 29 30 public int weight; 31 32 public boolean def; 33 34 public Severity() 35 { 36 37 39 } 40 41 42 public Severity (int id) 43 { 44 try 45 { 46 47 Connection d = DatabaseConnectionPool.getConnection(); 48 Statement st = d.createStatement(); 49 ResultSet rs = st.executeQuery("select * from severity where severity_id=" + id); 50 51 while (rs.next()) 52 { 53 54 severityID = id; 55 56 severity = rs.getString(1); 57 58 weight = rs.getInt(2); 59 60 def = rs.getInt(3) == 1; 61 62 } 63 64 st.close(); 65 DatabaseConnectionPool.freeConnection(d); 66 67 } 68 69 catch (Exception E) 70 { 71 72 74 } 75 } 77 78 public String getName() 79 { 80 81 return severity; 82 83 } 85 86 public int getID() 87 { 88 89 return severityID; 90 91 } 93 94 public int getWeight() 95 { 96 97 return weight; 98 99 } 101 102 public boolean isDefault() 103 { 104 105 return def; 106 107 } 109 110 113 public static Vector getSeverities() 114 { 115 116 Vector v = new Vector(); 117 118 try 119 { 120 Connection d = DatabaseConnectionPool.getConnection(); 121 Statement st = d.createStatement(); 122 ResultSet rs = st.executeQuery("select severity_id from severity order by def"); 123 124 while (rs.next()) 125 { 126 127 v.add( new Severity( rs.getInt( 1 ) ) ); 128 129 } 130 131 st.close(); 132 DatabaseConnectionPool.freeConnection(d); 133 return v; 134 } 135 136 catch (Exception E) 137 { 138 139 E.printStackTrace(); 140 v.add( new String ("Error") ); 141 v.add( E.getMessage() ); 142 return v; 143 144 } 145 146 } 148 149 } | Popular Tags |