jdbc PSQLException: ОШИБКА: синтаксическая ошибка в или около "КОНФЛИКТА" - PullRequest
0 голосов
/ 22 ноября 2018

Я пытаюсь обновить таблицу в моей базе данных postgres с помощью JDBC, и для большинства моих запросов она работает просто отлично.Но иногда я получаю эту ошибку:

org.postgresql.util.PSQLException: ERROR: syntax error at or near "CONFLICT"

Когда я делаю запрос вручную в postgres, он прекрасно работает:

INSERT INTO user_jira (key_user,account_id,name_user,email_adress,display_name,active)
VALUES ('admin','5a283eThisIsJustAnExample','admin','john.john@proceedit.com','john john',true)
ON CONFLICT (key_user) 
DO UPDATE 
  SET account_id=excluded.account_id,
      name_user=excluded.name_user,
      email_adress=excluded.email_adress,
      display_name=excluded.display_name,
      active=excluded.active;

Кто-нибудь знает, что происходит?Изменить: вот как я подключаюсь к БД и отправляю свой запрос:

    String url = "jdbc:postgresql://host:port/db";//connect(url);
    Properties props = new Properties();
    props.setProperty("user","user");
    props.setProperty("password","*********");
    try {
        dyDATAconn = DriverManager.getConnection(url, props);
        System.out.println("connected to "+url);
        Statement st;
         //sql statement
        st = dyDATAconn.createStatement();
        int userRowInserted = st.executeUpdate(User.sqlUpdate(newUser));
        int taskRowInserted = st.executeUpdate(Task.sqlUpdate(allTask));
        int timeSpentRowInserted = st.executeUpdate(TimeSpent.sqlUpdate(allTimeSpent));
        System.out.println("tsk: "+taskRowInserted+"\nTS:"+timeSpentRowInserted);
    } catch (SQLException e) {
        System.out.println("connection to dyJIRA@dyDATA failed");
        System.out.println(User.sqlUpdate(newUser));
        e.printStackTrace();
        return -1;
    }

Я не могу показать, как я создаю свой запрос, но я получил только pb с пользователями, и все запросы имеют одинаковый форматкак выше

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...