Problem while inserting a byte array into a bytea column - Mailing list pgsql-general

From Ricardo Camacho
Subject Problem while inserting a byte array into a bytea column
Date
Msg-id 200206071656.35825.ricardo.camacho@inov.pt
Whole thread Raw
List pgsql-general
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 by date:

Previous
From: Arthur
Date:
Subject: Re: Slow connection
Next
From: "M.L.Bowman"
Date:
Subject: deny table creation