org.postgresql.util.PSQLException: ERROR: column "file" is of type oid but expression is of type bytea
От | peter.penzov |
---|---|
Тема | org.postgresql.util.PSQLException: ERROR: column "file" is of type oid but expression is of type bytea |
Дата | |
Msg-id | 1462562098748-5902345.post@n5.nabble.com обсуждение исходный текст |
Ответы |
Re: org.postgresql.util.PSQLException: ERROR: column "file" is of
type oid but expression is of type bytea
Re: org.postgresql.util.PSQLException: ERROR: column "file" is oftype oid but expression is of type bytea |
Список | pgsql-jdbc |
I want to implement file upload into PostgreSQL using JSF page. I tried this code: public void upload() throws SQLException, GSSException { if (file != null) { try { InputStream inputStream = file.getInputStream(); Connection conn = ds.getConnection(); PreparedStatement ps = null; boolean committed = false; try { conn.setAutoCommit(false); ps = conn.prepareStatement("INSERT INTO PROCEDURE_FILES (ID, PROCEDURE_ID, FILE_NAME, FILE) " + " VALUES (?, ?, ?, ?)"); ps.setInt(1, obj.number); ps.setInt(2, obj.number); ps.setString(3, file.getSubmittedFileName()); ps.setBinaryStream(4, inputStream, inputStream.available()); ps.executeUpdate(); ps.close(); conn.commit(); committed = true; } catch (SQLException e) { e.printStackTrace(); } finally { if (!committed) { conn.rollback(); } if (ps != null) { ps.close(); } conn.close(); } FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Upload successfully ended!")); } catch (IOException e) { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Upload failed!")); } } } But I get error error: org.postgresql.util.PSQLException: ERROR: column "file" is of type oid but expression is of type bytea Hint: You will need to rewrite or cast the expression. Position: 86 What is the proper way to cast the Object? -- View this message in context: http://postgresql.nabble.com/org-postgresql-util-PSQLException-ERROR-column-file-is-of-type-oid-but-expression-is-of-type-bytea-tp5902345.html Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
В списке pgsql-jdbc по дате отправления: