AnsweredAssumed Answered

Extracting Images from Container Fields Using Java/JDBC - Examples?

Question asked by MorkAfur on May 25, 2012
Latest reply on May 25, 2012 by MorkAfur

Title

Extracting Images from Container Fields Using Java/JDBC - Examples?

Post

I am trying to get a test JPG image out of a FMP 12 Container field using Java.

I'm treating the container field as a Blob type, but the code isn't working.

The basic logic is here.

     // returns 1 row with image:

    String sql = "SELECT  GetAs(Picture, 'JPEG' ) as image FROM customer\n" +
                    "  where Services like '%Delivery%'  and name = 'Mike'";

            PreparedStatement stmt = connection.prepareStatement(sql);
            ResultSet rs = stmt.executeQuery();

             Blob blob = rs.getBlob(1); 
             bytesToWrite  = blob.getBytes(1, (int) blob.length());

            if (rs.next())
            {
                out.write(bytesToWrite);
            }

.

.

.

The basic error is:

Exception in thread "main" java.lang.NullPointerException
    at com.filemaker.jdbc3.J3ResultSet.getBlob(Unknown Source)

----------------------

This is standard boilerplate Java logic that should work.

The same query inside a database explorer returns data so I'm thinking it's that Blob isn't the right type of object to use above. Not sure, since no examples, however.

I've looked at the ODBC/JDBC reference for FMP 12, but there are zero examples of extracting container fields other than in a query, which doesn't match my current need.

Look forward to any suggestions.

Thanks,

-- m

Outcomes