Advertisement
Guest User

Untitled

a guest
Oct 4th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. public ArrayList<SpecVisual> Insertar_bocetos(String[] anuncios) {
  2.  
  3. String driver = "org.postgresql.Driver";
  4. String connectString = "jdbc:postgresql://db1.medellin.intrayell.com:5432/clipper";
  5. String user = "clipper";
  6. String password = "clipper";
  7.  
  8.  
  9. PreparedStatement ps = null;
  10. ResultSet rs = null;
  11. ResultSetMetaData rsmd = null;
  12.  
  13. SpecVisual specVisual = new SpecVisual();
  14. Advertiser advertiser = new Advertiser();
  15. ArrayList<SpecVisual> arrbocetos = new ArrayList<SpecVisual>();
  16.  
  17.  
  18.  
  19. try {
  20.  
  21. Class.forName(driver);
  22. Connection con = DriverManager.getConnection(connectString, user,
  23. password);
  24.  
  25.  
  26. StringBuilder sb = new StringBuilder("Select sp.clipper_Book_Id,sp.Book_Edition,"
  27. + "sp.creativity_id,sp.Awaiting_ref_flag,sp.type_Id,sp.pub_ad_code,sp.heading_name,"
  28. + "sp.Login_Id,sp.sales_rep_code,ad.advertiser_name,ad.clipper_advertiser_ref,sp.language_id,sp.multi_page_flag "
  29. + "from advertiser ad,Spec_visual sp "
  30. + "where sp.clipper_advertiser_ref= ad.clipper_advertiser_ref and sp.clipper_wi_ref in (");
  31.  
  32. for(int i=0;i<anuncios.length;i++){
  33. if(i>0){
  34. sb.append(",");
  35. }
  36. sb.append("?");
  37. }
  38. sb.append(")");
  39.  
  40. ps = con.prepareStatement(sb.toString());
  41. for(int i=0;i<anuncios.length;i++){
  42. ps.setString(i+1, anuncios[i]);
  43. }
  44.  
  45. rs = ps.executeQuery();
  46.  
  47. while (rs.next()) {
  48.  
  49. specVisual
  50. .setClipperBookId(rs.getString("clipper_Book_Id"));
  51. specVisual.setBookEditionId(Long.parseLong(rs
  52. .getString("Book_Edition")));
  53. specVisual.setCreativityId(Integer.parseInt(rs
  54. .getString("creativity_id")));
  55. specVisual.setAwaitRefFlag(Integer.parseInt(rs
  56. .getString("Awaiting_ref_flag")));
  57. specVisual.setTypeId(Integer.parseInt(rs
  58. .getString("type_Id")));
  59. specVisual.setPubAdCode(rs.getString("pub_ad_code"));
  60. specVisual.setHeadingName(rs.getString("heading_name"));
  61. specVisual.setLoginId(rs.getString("Login_Id"));
  62. specVisual.setSalesRepCode(rs.getString("sales_rep_code"));
  63.  
  64. advertiser.setAdvertiserName(rs
  65. .getString("advertiser_name"));
  66. advertiser.setClipperAdvertiserRef(rs
  67. .getString("clipper_advertiser_ref"));
  68.  
  69. specVisual.setAdvertiser(advertiser);
  70. specVisual.setLanguageId(Integer.parseInt(rs
  71. .getString("language_id")));
  72. specVisual.setMultiPageFlag(Integer.parseInt(rs
  73. .getString("multi_page_flag")));
  74. // specVisual.setTypeInstructionsText("specVisualFB.getInstructions()");
  75. arrbocetos.add(specVisual);
  76.  
  77. }
  78.  
  79.  
  80. }
  81. catch (Exception e) {
  82. System.out.println(e.getMessage());
  83. }
  84. finally{
  85.  
  86. ps.close();
  87. con.close();
  88. rs.close();
  89. return arrbocetos;
  90. }
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement