/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/StationDAO.java
ViewVC logotype

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/StationDAO.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 588 by torben, Mon Feb 8 19:12:15 2010 UTC revision 589 by torben, Mon Feb 8 19:25:12 2010 UTC
# Line 40  public class StationDAO { Line 40  public class StationDAO {
40                        "FROM trainstations WHERE id=" + id + " AND enabled=true";                        "FROM trainstations WHERE id=" + id + " AND enabled=true";
41                                    
42                  Connection conn = null;                  Connection conn = null;
43                    Statement stmt = null;
44                    ResultSet res = null;
45                  StationBean result;                  StationBean result;
46                                    
47                  try {                  try {
48                          conn = DBConnection.getConnection();                          conn = DBConnection.getConnection();
49                                    
50                          Statement stmt = conn.createStatement();                          stmt = conn.createStatement();
51                          ResultSet res = stmt.executeQuery(SQL);                                  res = stmt.executeQuery(SQL);          
52                          res.next();                          res.next();
53                          result = convertSingleRow(res);                          result = convertSingleRow(res);
54                  } finally {                  } finally {
55                            if (res != null)
56                                    res.close();
57                            if (stmt != null)
58                                    stmt.close();
59                          if (conn != null)                          if (conn != null)
60                                  conn.close();                                  conn.close();
61                  }                  }
# Line 67  public class StationDAO { Line 73  public class StationDAO {
73                                    
74                  List<StationBean> result;                  List<StationBean> result;
75                  Connection conn = null;                  Connection conn = null;
76                    PreparedStatement stmt = null;
77                    ResultSet res = null;
78                  try {                  try {
79                          conn = DBConnection.getConnection();                          conn = DBConnection.getConnection();
80                          PreparedStatement stmt = conn.prepareStatement(SQL);                          stmt = conn.prepareStatement(SQL);
81                                                    
82                          stmt.setString(1, name + "%");                          stmt.setString(1, name + "%");
83                                                    
84                          ResultSet rs = stmt.executeQuery();                          res = stmt.executeQuery();
85                          result = convertResultset(rs);                          result = convertResultset(res);
86                                                    
87                  } finally {                  } finally {
88                          if (conn != null)                          if (res != null)
89                                    res.close();
90                            if (stmt != null)
91                                    stmt.close();
92                            if (conn!= null)
93                                  conn.close();                                  conn.close();
94                  }                  }
95                  return result;                  return result;
# Line 94  public class StationDAO { Line 106  public class StationDAO {
106                  "LIMIT 4 ";                  "LIMIT 4 ";
107                  List<StationBean> result;                  List<StationBean> result;
108                  Connection conn = null;                  Connection conn = null;
109                    PreparedStatement stmt = null;
110                    ResultSet res = null;
111                  try {                  try {
112                          conn = DBConnection.getConnection();                          conn = DBConnection.getConnection();
113                          PreparedStatement stmt = conn.prepareStatement(SQL);                          stmt = conn.prepareStatement(SQL);
114                          stmt.setDouble(1, latitude);                          stmt.setDouble(1, latitude);
115                          stmt.setDouble(2, longitude);                          stmt.setDouble(2, longitude);
116                          ResultSet rs = stmt.executeQuery();                          res = stmt.executeQuery();
117                          result = convertResultset(rs);                          result = convertResultset(res);
118                                                    
119                  } finally {                  } finally {
120                          if (conn != null)                          if (res != null)
121                                    res.close();
122                            if (stmt != null)
123                                    stmt.close();
124                            if (conn!= null)
125                                  conn.close();                                  conn.close();
126                  }                  }
127                  return result;                  return result;
# Line 116  public class StationDAO { Line 134  public class StationDAO {
134                          "ORDER BY name ";                          "ORDER BY name ";
135                                                    
136                          Connection conn = null;                          Connection conn = null;
137                            Statement stmt = null;
138                            ResultSet res = null;
139                          List<StationBean> result;                          List<StationBean> result;
140                                                    
141                          try {                          try {
142                                  conn = DBConnection.getConnection();                                  conn = DBConnection.getConnection();
143                                  Statement stmt = conn.createStatement();                                  stmt = conn.createStatement();
144                                  ResultSet res = stmt.executeQuery(SQL);                                  res = stmt.executeQuery(SQL);
145                                  result = convertResultset(res);                                  result = convertResultset(res);
146                          } finally {                          } finally {
147                                    if (res != null)
148                                            res.close();
149                                    if (stmt != null)
150                                            stmt.close();
151                                  if (conn!= null)                                  if (conn!= null)
152                                          conn.close();                                          conn.close();
153                          }                          }

Legend:
Removed from v.588  
changed lines
  Added in v.589

  ViewVC Help
Powered by ViewVC 1.1.20