Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- //using namespace std;
- #include <stdio.h>
- #include "libpq-fe.h"
- #include <string>
- #include <cstdio>
- #include <stdlib.h>
- int main() {
- PGconn *conn;
- PGresult *res;
- int rec_count;
- int row;
- int col;
- FILE *stream;
- conn = PQconnectdb("hostaddr=192.168.143.93 port=5432 connect_timeout=10 dbname=NexentaSearch user=postgres password=postgres");
- if (PQstatus(conn) == CONNECTION_BAD) {
- fprintf(stderr, "Connection to database failed: %sn",PQerrorMessage(conn));
- puts("No connection");
- exit(0);
- }
- res = PQexec(conn, "select path from tasks order by id");
- if (PQresultStatus(res) != PGRES_TUPLES_OK) {
- printf("We didn't get the data");
- exit(0);
- }
- rec_count = PQntuples(res);
- Connection con = DriverManager.getConnection(url, user, pass);
- ArrayList<String> arrayString = new ArrayList<String>();
- String query = "тут запрос";
- ResultSet res = con.createStatement.executeQuery(query);
- while (res.next) {
- arrayString.add(res.getString("1"))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement