Problem while inserting a byte array into a bytea column

Поиск
Список
Период
Сортировка
Искать
От
Ricardo Camacho
Тема
Problem while inserting a byte array into a bytea column
Дата
Msg-id
200206071656.35825.ricardo.camacho@inov.pt
Список
This is the statement initilization---------------------------------------------------------------------------------------------
      PreparedStatement newFile = dbConnection.prepareStatement("insert into gm_files values (?,?,?,?)");
--------------------------------------------------------------------------------------------------------------------------------------
This is the database table struct --------------------------------------------------------------------------------------------
	Column		data-type		size
	--------------------------------------------
	reference		text			N/A
	nome		text			N/A
	date			datetime		N/A
	content		bytea		N/A
--------------------------------------------------------------------------------------------------------------------------------------
This is the code i am using to insert the file into the database. -------------------------------------------------------
  public synchronized boolean createFile (String reference, String name, Date index, byte[] content) {
    try {
      newFile.getConnection().setAutoCommit(false);
      content = ZipUtils.compress(content);
      System.out.println("After compression file is " + content.length);
      java.io.ByteArrayInputStream bytes = new java.io.ByteArrayInputStream(content);
      newFile.setString(1, reference);
      newFile.setString(2, name);
      newFile.setTimestamp(3, AbstractDB.getTimeStamp(index));
      newFile.setBinaryStream(4, bytes, content.length);
      newFile.executeUpdate();
      newFile.getConnection().commit();
      newFile.getConnection().setAutoCommit(true);
      return true;
    } catch (Exception ex) {
      ex.printStackTrace();
      return  false;
    }
  }
--------------------------------------------------------------------------------------------------------------------------------------

When it gets to the executeUpdate() it returns the following error----------------------------------------------------

	java.sql.SQLException: ERROR:  column "content" is of type 'bytea' but expression is of type 'integer'
 	       You will need to rewrite or cast the expression
--------------------------------------------------------------------------------------------------------------------------------------
В списке pgsql-general по дате отправления
От: Arthur
Дата:
Сообщение: Re: Slow connection
От: M.L.Bowman
Дата:
Сообщение: deny table creation
FAQ