日期:2014-05-17 浏览次数:20734 次
public List<FailedType> getFailedType(){ List<FailedType> failedTypes = new ArrayList<FailedType>(); String sql = "SELECT FAILED_TYPE,FAILED_NO FROM T_FAILED_TYPE WHERE ID = ?"; Connection connect = DBConnectFactory.getDBConnect(); ResultSet rs = null; try { PreparedStatement ps = connect.prepareStatement(sql.toString()); ps.setString(1, "111"); rs = ps.executeQuery(); while (rs.next()) { FailedType failedType = new FailedType(); String type = rs.getString("FAILED_TYPE"); String no = rs.getString("FAILED_NO"); failedType.setFailedType(type); failedType.setFailedNo(no); failedTypes.add(failedType); } } catch (SQLException e) { logger.error(e.getMessage()); e.printStackTrace(); } finally { DBConnectFactory.closeResultSet(rs); } return failedTypes; }
------解决方案--------------------
呃。。。这个忘得有点多了
------解决方案--------------------
是用jdbc取值么
select * from table where id=?
------解决方案--------------------
那如果你用了什么框架之类的,就好好去看看框架的使用。我写的是jdbc的