AnsweredAssumed Answered

FileMaker 16 JDBC driver does not support reusing PreparedStatements

Question asked by jbarnum on Nov 17, 2017
Latest reply on Nov 17, 2017 by TSGal

PreparedStatements are designed to be stored and re-used with different parameters. However, the FileMaker 16 JDBC driver will give an error that "Cursor has been closed" if you attempt to re-use the same PreparedStatement. This is not an edge case, this is the normal way that you interact with JDBC. This is a show-stopping problem, making the FM 16 JDBC driver essentially unusable. This bug did not exist in the FM 15 JDBC driver. To make matters worse, FileMaker Cloud now requires the FM 16 JDBC driver, which means that using the FM 15 JDBC driver is not an available workaround if using FileMaker Cloud.


This is a really big problem. Please try to fix ASAP.


Here is a test case demonstrating the problem:


package com.prosc.nativejdbc;


import junit.framework.TestCase;


import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;


public class ReusePreparedStatement extends TestCase {

   public void test() throws Exception {

  Class.forName( "com.filemaker.jdbc.Driver" );

   try( Connection connection = DriverManager.getConnection( "jdbc:filemaker:// speed tests", "test", "test" );

  PreparedStatement ps = connection.prepareStatement( "SELECT Color FROM SampleData WHERE ID=?" )

  ) {

   //Doing the first query with the PreparedStatement works OK
   ps.setInt( 1, 502039 );

  ResultSet rs1 = ps.executeQuery();;

  System.out.println("Color is " + rs1.getString( 1 ) );



   //Attempting to re-use the same PreparedStatement for a different query with a different parameter fails
   ps.setInt( 1, 502040 );

  ResultSet rs2 = ps.executeQuery();; // <---- Test case fails here with 16 JDBC driver. Does not fail with 15 JDBC driver.
   System.out.println("Color is " + rs2.getString( 1 ) );