Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. 98 ...
  2. 99 String strQuery = "INSERT INTO public.alarm (entity, duration, first, type, windowsize) VALUES (?, ?, ?, 'dur', 6)";
  3. 100
  4. 101 JDBCOutputFormat jdbcOutput = JDBCOutputFormat.buildJDBCOutputFormat()
  5. 102 .setDrivername("org.postgresql.Driver")
  6. 103 .setDBUrl("jdbc:postgresql://localhost:5432/postgres?user=michel&password=polnareff")
  7. 104 .setQuery(strQuery)
  8. 105 .setSqlTypes(new int[] { Types.VARCHAR, Types.INTEGER, Types.VARCHAR}) //set the types
  9. 106 .finish();
  10. 107
  11. 108 DataStream<Row> rows = FilterStream
  12. 109 .map((tuple)-> {
  13. 110 Row row = new Row(3); // our prepared statement has 3 parameters
  14. 111 row.setField(0, tuple.f0); // first parameter is case ID
  15. 112 row.setField(1, tuple.f1); // second paramater is tracehash
  16. 113 row.setField(2, f.format(tuple.f2)); // third paramater is tracehash
  17. 114 return row;
  18. 115 });
  19. 116
  20. 117 rows.writeUsingOutputFormat(jdbcOutput);
  21. 118
  22. 119 env.execute();
  23. 120
  24. 121 }
  25. 122 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement