Advertisement
Guest User

Untitled

a guest
Jan 7th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. //using namespace std;
  4.  
  5. #include <stdio.h>
  6. #include "libpq-fe.h"
  7. #include <string>
  8. #include <cstdio>
  9. #include <stdlib.h>
  10.  
  11. int main() {
  12. PGconn *conn;
  13. PGresult *res;
  14. int rec_count;
  15. int row;
  16. int col;
  17. FILE *stream;
  18.  
  19. conn = PQconnectdb("hostaddr=192.168.143.93 port=5432 connect_timeout=10 dbname=NexentaSearch user=postgres password=postgres");
  20. if (PQstatus(conn) == CONNECTION_BAD) {
  21. fprintf(stderr, "Connection to database failed: %sn",PQerrorMessage(conn));
  22. puts("No connection");
  23. exit(0);
  24. }
  25.  
  26. res = PQexec(conn, "select path from tasks order by id");
  27.  
  28. if (PQresultStatus(res) != PGRES_TUPLES_OK) {
  29. printf("We didn't get the data");
  30. exit(0);
  31. }
  32.  
  33. rec_count = PQntuples(res);
  34.  
  35. Connection con = DriverManager.getConnection(url, user, pass);
  36. ArrayList<String> arrayString = new ArrayList<String>();
  37. String query = "тут запрос";
  38.  
  39. ResultSet res = con.createStatement.executeQuery(query);
  40.  
  41. while (res.next) {
  42. arrayString.add(res.getString("1"))
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement