Extracting Images from Container Fields Using Java/JDBC - Examples?
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());
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.
This is resolved.
The issue is that the Container field is not treated as Blob field in the java code.
Found this useful site for anyone in the same situation: http://www.skeletonkey.com/FileMaker_Container_Fields_JDBC