4 Replies Latest reply on May 7, 2010 2:41 PM by actualjon

    FM11 JDBC Driver: FMSQLException constructor fails.



      FM11 JDBC Driver: FMSQLException constructor fails.

      Description of the issue

      FM11 JDBC Driver on Windows using JDK 1.6.0u19 x64 connected to FM11 server on Windows 2008 R2 x64:When executing a query like "SELECT * FROM some_table" the JDBC driver throws this exception: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 11    at java.lang.String.substring(String.java:1934)    at com.filemaker.jdbc.FMSQLException.(Unknown Source)    at com.filemaker.jdbc.FM_API.getAllResults(Unknown Source)    at com.filemaker.jdbc.FM_API.execute(Unknown Source)    at com.filemaker.jdbc.FM_API.execute(Unknown Source)    at com.filemaker.jdbc1.CommonJ1Statement.execute(Unknown Source)    at com.filemaker.jdbc2.CommonJ2Statement.execute(Unknown Source)    at com.filemaker.jdbc1.CommonJ1Statement.executeQuery(Unknown Source)    at com.filemaker.jdbc1.CommonJ1Statement.executeQuery(Unknown Source)    at MyClass.myMethod... This reads like "Error displaying error message". ;) The value of the String was "65527". Selecting some distinct fields instead of * worked. I didn't try other tables. The cause for the FMSQLException isn't really important anyway. The actual problem is that the FMSQLException constructor throws an exception. 

        • 1. Re: FM11 JDBC Driver: FMSQLException constructor fails.



          Thank you for your post.


          If you specify all the fields instead of the asterisk, do you still get the same error?  If you specify the field that contains the string, do you get the same error?  I'm just trying to hopefully narrow down the cause.



          FileMaker, Inc.

          • 2. Re: FM11 JDBC Driver: FMSQLException constructor fails.

            To avoid confusion let me first clarify the issue. There are actually two issues.


            Issue 1: FMSQLException constructor throws StringIndexOutOfBoundsException


            I'm calling executeQuery (see [1]):


            ResultSet rs=someStatement.executeQuery("SELECT * FROM some_table");

            Expected result:

            The query succeeds and executeQuery returns a ResultSet


            an error occurs and executeQuery throws a SQLException that contains a hopefully meaningful error message.


            Actual result:


            executeQuery throws a StringIndexOutOfBoundsException.


            The stack trace in my first post shows that the StringIndexOutOfBoundsException was caused in the constructor of FMSQLException (which presumably is a subclass of the expected SQLException), because the constructor called substring (see [2]) with a value of 11 for beginIndex or endIndex on a String that is shorter than 11 characters. That's pretty clearly a bug in the constructor of FMSQLException (which is part of the JDBC driver).

            The value of the String was "65527". I have no idea where that value comes from but I'm quite sure that it's not in the table (can't look it up from where I am now).


            An unpleasant side effect of this bug is that the StringIndexOutOfBoundsException "hides" the about to be thrown FMSQLException and I don't get that hopefully meaningful error message for...


            Issue 2:

            "SELECT * FROM some_table" shouldn't cause an error. And before upgrading to FM 11 it didn't. The only thing I changed in the application was replacing the old Sequelink JDBC driver with the new Filemaker 11 JDBC driver. After changing the query to "SELECT field1, field2, ... FROM some_table" the query succeeded. But I only selected a few fields. I'll try all when I'm back at work tomorrow. I'll also verify whether the string "65527" is in the table then.


            [1] http://java.sun.com/javase/6/docs/api/java/sql/Statement.html#executeQuery%28java.lang.String%29

            [2] http://java.sun.com/javase/6/docs/api/java/lang/String.html#substring%28int,%20int%29

            • 3. Re: FM11 JDBC Driver: FMSQLException constructor fails.



              Thanks for the additional information.


              I apologize for my first post.  I should have been more clear.  With the information I had, I wanted to try and narrow down the cause.  The asterisk should work, but I wanted to try and isolate it and see if a particular field is causing the issue.


              How many fields are being requested?  Do any fields contain a large amount of content?  Anything else you can think of that may affect the query would be appreciated.



              FileMaker, Inc.

              • 4. Re: FM11 JDBC Driver: FMSQLException constructor fails.

                Have you tried executing the same query using an ODBC application (like MS Excel or MS Access)?  


                Since ODBC and JDBC use the same SQL engine, you might be able to find out the true error message from an ODBC application (that doesn't have the same problem with the FMSQLException constructor).


                Jonathan Monroe

                Actual Technologies