Exemplo n.º 1
0
 // Usado no conversor
 public Tag porId(Integer id) throws SQLException {
   Tag tag = null;
   String sql = "select tag_id as id, tag_nome as nome from tag where tag_id=?;";
   pstm = con.prepareStatement(sql);
   pstm.setInt(1, id);
   System.out.println(pstm.toString());
   rs = pstm.executeQuery();
   while (rs.next()) {
     tag = new Tag();
     tag.setId(rs.getInt("id"));
     tag.setNome(rs.getString("nome"));
   }
   return tag;
 }
Exemplo n.º 2
0
 public List<Tag> queContem(String nome) throws SQLException {
   List<Tag> tags = new ArrayList<>();
   Tag tag = null;
   String sql = "select tag_id as id, tag_nome as nome from tag where tag_nome like ?;";
   pstm = con.prepareStatement(sql);
   pstm.setString(1, "%" + nome + "%");
   System.out.println(pstm.toString());
   rs = pstm.executeQuery();
   while (rs.next()) {
     tag = new Tag();
     tag.setId(rs.getInt("id"));
     tag.setNome(rs.getString("nome"));
     tags.add(tag);
   }
   return tags;
 }