Do you use latest driver and JRE?
Yup, I do lots with JDBC and FileMaker. Never gotten this error.
-- What version of FileMaker and its JDBC driver are you using?
There were some bugs in the last FMP 13 JDBC driver, but I didn't see this issue. The bug I found was that if you try to read twice from a ResultSet (rather than just copy the value the first read to a variable, for exmaple), the second time, reading from the ResultSet, the value would be empty. FM fixed that issue in FMP 14's version of the JDBC driver.
-- Are you using Windows or Mac?
-- Are you sure you actually have a connection to the database in the first place when you're initializing the PreparedStatement?
Maybe you're closing the connection somewhere in code?
I normally create a connection like this:
(read from properties file)
final String FMP_JDBC_DRIVER = props.getProperty("FMP_JDBC_DRIVER");
final String FMP_DATABASE_URL = props.getProperty("FMP_DATABASE_URL");
final String fmp_user = props.getProperty("fmp_user");
final String fmp_password = props.getProperty("fmp_password");
// establish connection to FileMaker Pro
fmpConnection = DriverManager.getConnection(FMP_DATABASE_URL, fmp_user, fmp_password);
At this point, the fmpConnection variable should have an object reference in it.
Then, create your PreparedStatement:
final java.sql.PreparedStatement fmpPreparedStatement =
(making these variables "final" is just a compiler optimization added after code inspection and won't affect your run/crash results.)
I'm assuming you've stepped through your code and have made sure your have objects at each of the steps above, right?
If you can't get this much working, or some of the code above crashes, post your code and I'll take a look.
I would also test your PreparedStatement SQL to make sure it doesn't have any typos. That's an easy issue to have.
HOPE THIS HELPS.
FM Server 11.05 on Windows in this particular instance. The code is built with the latest driver from FM14.
I may have found the issue in my code, pending confirmation... I found a thread that might execute a query on the main connection concurrently with another thread (a huge no-no for JDBC)
Thank you for your replies
Yes, from my double checking, the JDBC spec doesn't guarantee correct results with multi-threading.
But, in at least one example, the MySQL Connector/J,
execute'sstatements lock the connection with a
So, if one thread is running a query, other threads using the connection will be blocked until it finishes.
Depends on your driver, the version of the driver, the version of the JVM, and all the potential race conditions that could occur. If you possibly abstract your database layer with something like "Hibernate" (hibernate.org), it may also help.
HOPE THIS HELPS.