I'm running Postgresql 7.1.2 on a RedHat 7.1 machine. I have the jdbc
drivers jdbc7.1-1.2.jar.

I have been trying to figure out how the blob support works. I made a
table of this format:

djweis=# \d blobtest
 id        | integer | 
 theblob   | bytea   | 

This is the code that I'm using to grab the value of 'theblob':

            conn.setAutoCommit(false);

            PreparedStatement stmt = conn.prepareStatement("SELECT theblob
FROM blobtest WHERE id = ?");
            stmt.setInt(1, 1);
            ResultSet rset = stmt.executeQuery();

            while (rset.next()) {

                Blob foo = rset.getBlob("theblob");

                System.out.println("length is " + foo.length());

            }

But instead of getting just the length, I get this:

[djweis@djweis pgblob]$ java -cp jdbc7.1-1.2.jar:. test
hello, world
Bad Integer I wish this would work
        at org.postgresql.jdbc2.ResultSet.getInt(ResultSet.java:269)
        at org.postgresql.jdbc2.ResultSet.getBlob(ResultSet.java:964)
        at org.postgresql.jdbc2.ResultSet.getBlob(ResultSet.java:959)
        at test.main(test.java:30)
Bad Integer I wish this would work
[djweis@djweis pgblob]$ 

I never printed the contents of the blob, but there they are... I inserted
the data by hand, but once I figure out how to do this, I'll need to
insert the data from InputStreams and get it back using OutputStreams.

Any ideas?

Thanks
dave


-- 
Dave Weis             "I believe there are more instances of the abridgement
[EMAIL PROTECTED]   of the freedom of the people by gradual and silent
                      encroachments of those in power than by violent 
                      and sudden usurpations."- James Madison


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl

Reply via email to