5 Replies Latest reply on Mar 12, 2013 7:53 AM by PeterWagemans

    Unable to get Blobs from DB with JDBC

    OnnoTijdgat

      Summary

      Unable to get Blobs from DB with JDBC

      Product

      FileMaker Server

      Version

      FM Server 11 Advanced v1

      Operating system version

      Mac OS X 10.6.4

      Description of the issue

      Using FM 11 Server Advanced as a data source in a Java/jsp project. The connection with the database is made thru jdbc.

      In principle this works fine. However, I am having trouble retrieving the contents of FM container fields. I should be able to do something like xyz.getBlob(colIdx) to get a Blob object refering to the FM container. xyz is a ResultSet object containing the result of an SQL query.

      However this blob object is always null. Inspecting the Resultset shows that indeed the container fields are always null. (Yes, the DB has data of various forms in all container fields). The field type returned is -4, LONGVARBINARY, which is correct.

      I tried a simple SELECT *, SELECT GetAs() and i never get any non null data.

      Inserting blobs does work.

      See also the discussion at: http://forums.filemaker.com/posts/4d1cc9ffd7

      Steps to reproduce the problem

      See also: http://forums.filemaker.com/posts/4d1cc9ffd7 Noone seems to be able to get it working.

      Expected result

      a non null blob object

      Actual result

      null

      Exact text of any error message(s) that appear

      none.

      Workaround

      none

        • 1. Re: Unable to get Blobs from DB with JDBC
          TSGal

          Onno Tijdgat:

          Thank you for your post and the link to your original thread.

          I have forwarded the information to our Development and Software Quality Assurance (Testing) departments for review and confirmation.  When information becomes available for you, I will let you know.

          TSGal
          FileMaker, Inc.

          • 2. Re: Unable to get Blobs from DB with JDBC
            TSGal

            Onno Tijdgat:

            Our Testing department has confirmed the problem.  The workaround is to use ResultSet.getBinaryStream() instead of ResultSet.getBlob().

            TSGal
            FileMaker, Inc.

            • 3. Re: Unable to get Blobs from DB with JDBC
              PeterWagemans

                   I'm trying to do the same thing Onno does, but I get a null result for getBlob as well.

                   I am trying to get a result using

                   

                        InputStream myContainerStream = myResultSet.getBinaryStream("FileMakerContainerField");

                   but I get a null result there as well. Same result for the getBytes method.

                   I have tested with FileMaker Server 12.0.3.327. Seems the most recent version at the time of this post.

                   This is the only place here that I found where there's an exact question - and an exact answer.

                   I hope this is not yet again a problem 3 years later and that I get an answer as straight as the previous one. I know Onno, we used to work for Apple. I'll ask him as well how he got around this issue. Maybe it wás fixed but broken again. Thanks.

              • 4. Re: Unable to get Blobs from DB with JDBC
                PeterWagemans

                     FYI, I just got a message from Onno that he gave up solving the problem using FileMaker and choose another product for the project where initially FileMaker Server was decided on. So probably even the workaround did not work.

                • 5. Re: Unable to get Blobs from DB with JDBC
                  PeterWagemans

                       OK, I got it. Not a bug.

                       You have to know how to retrieve the data. You have to use GetAs() with the correct stream type.

                       This puts me in a pickle. A generic "SELECT *" retrieves several records with each column an unpredicatable data type. I can put this in a decision tree, and detect a longvarbinary to know I'm retrieving a container field.

                       But then I have to re-query I guess to first cast that field as a varchar, in order to get the container info, parse out what possible data could be in it, then re-query a 3th time with the correct GetAs(<streamtype>) to be able finally to get a binaryStream.

                       That seems like a slow and painful way to do it. Does anyone know an easier way?