protected List<Network> readDB(String sql) { List<Network> result = new ArrayList<Network>(); try { Connection c = XceAdapter.getInstance().getReadConnection("common"); try { Statement s = c.createStatement(); try { ResultSet rs = s.executeQuery(sql); while (rs.next()) { Network info = new Network(); info.setId(rs.getInt("id")); info.setUserId(rs.getInt("userid")); info.setStage(rs.getInt("stage")); info.setNetworkId(rs.getInt("network_id")); info.setNetworkName(rs.getString("network_name")); info.setInfoId(rs.getInt("info_id")); info.setJoinTime(DateFormatter.parse(rs.getString("join_time"))); info.setStatus(rs.getInt("status")); result.add(info); } rs.close(); } catch (Exception e) { e.printStackTrace(); Assert.assertFalse(true); } finally { s.close(); } } catch (Exception e) { e.printStackTrace(); Assert.assertFalse(true); } finally { c.close(); } } catch (Exception e) { e.printStackTrace(); Assert.assertFalse(true); } return result; }
protected void writeDB(String sql) { try { Connection c = XceAdapter.getInstance().getWriteConnection("common"); try { Statement s = c.createStatement(); try { s.execute(sql); } catch (Exception e) { e.printStackTrace(); Assert.assertFalse(true); } finally { s.close(); } } catch (Exception e) { e.printStackTrace(); Assert.assertFalse(true); } finally { c.close(); } } catch (Exception e) { e.printStackTrace(); Assert.assertFalse(true); } }