Developer’s Guide

Table Of Contents
9-6 Developer’s Guide
inventoryStatement.executeQuery("select *
from \"inventory.fp5\"");
// create a statement for closing the "inventory.fp5"
// database
CallableStatement closeDbStatement =
adminConnection.prepareCall("{call
dbclose(\"inventory.fp5\")}");
closeDbStatement.execute();
}
catch(ClassNotFoundException classNotFoundException)
{
System.out.println("Could not load driver");
}
catch(SQLException sqlException)
{
System.out.println("JDBC Error: " +
sqlException.getMessage());
}
}
}
Using the RecordID pseudo column
The FileMaker JDBC Driver provides a RecordID pseudo column
(in place of a primary key used by other types of databases) that can
be specified in the column name list of a SELECT statement or in the
WHERE clause of SELECT, UPDATE or DELETE statements. This
lets you guarantee that the statement will operate on a specific
record.
All other columns are ignored when the RecordID pseudo column is
used in a WHERE clause.
UPDATE "Employees.fp5" SET department='engineering' WHERE
recordid=4
Using the ModID pseudo column
Each record in a FileMaker Pro database has a corresponding
modification ID (ModID) number that increases incrementally every
time the record is modified. To detect modification collisions, the
FileMaker JDBC Driver provides a ModID pseudo column that can
be used in the WHERE clause of an UPDATE statement in
conjunction with the RecordID. The Web Companion compares the
ModID in the WHERE clause to the current ModID of the record and
an error is returned if they do not match.
...
Connection connection = DriverManager.getConnection("jdbc:fmpro:
http://localhost", "some_user", "some_password");
Statement statement = connection.createStatement();
// retrieve all of the records where department equals "engineering"
ResultSet resultSet = statement.executeQuery("SELECT recordid,
modid, "last name", "first name" FROM \"Employees.fp5\" WHERE
department='engineering'");
// create an UPDATE statement for changing the department to "software
// engineering"
PreparedStatement preparedStatement =
connection.prepareStatement("UPDATE \"Employees.fp5\" SET
department='software engineering' WHERE recordid=? AND
modid=?");
while (resultSet.next())
{
// set the recordid parameter
preparedStatement.setString(1,
resultSet.getString("RECORDID"));
// set the modid parameter
preparedStatement.setString(2, resultSet.getString("MODID"));
// change the department from "engineering" to "software
// engineering"
preparedStatement.executeUpdate();
}
...