FileMaker 10 ® ODBC and JDBC Guide
© 2004-2009 FileMaker, Inc. All Rights Reserved. FileMaker, Inc. 5201 Patrick Henry Drive Santa Clara, California 95054 FileMaker, the file folder logo, Bento and the Bento logo are either trademarks or registered trademarks of FileMaker, Inc. in the U.S. and other countries. Mac and the Mac logo are the property of Apple Inc. registered in the U.S. and other countries. All other trademarks are the property of their respective owners. FileMaker documentation is copyrighted.
Contents Chapter 1 Introduction About this guide Using a FileMaker database as a data source Accessing a hosted FileMaker Pro database Limitations with third-party tools Networking requirements Updating files from previous versions Installing current drivers 7 7 8 8 8 9 9 Chapter 2 Installing FileMaker ODBC and JDBC client drivers Abiding by the license agreement Hardware and software requirements ODBC client driver requirements (Windows) ODBC client driver requirements (Mac OS) JDBC client driver require
FileMaker ODBC and JDBC Guide Using the JDBC client driver About the JDBC client driver Using a JDBC URL to connect to your database Specifying driver properties in the URL subname Verifying access via JDBC 21 21 22 24 25 Chapter 5 Supported standards Support for Unicode characters SQL statements SELECT statement SQL clauses FROM clause WHERE clause GROUP BY clause HAVING clause UNION operator ORDER BY clause FOR UPDATE clause DELETE statement INSERT statement UPDATE statement CREATE TABLE statement A
| Contents 5 Chapter 6 Mapping FileMaker fields to ODBC data types Chapter 7 Mapping FileMaker fields to JDBC data types Chapter 8 ODBC and JDBC error messages ODBC error messages ODBC driver error messages ODBC Driver Manager error messages SequeLink Client error messages SequeLink Server error messages Data source error messages JDBC error messages JDBC driver error messages SequeLink Server error messages Data source error messages 51 51 51 51 52 52 52 52 52 53 Index 55
FileMaker ODBC and JDBC Guide
Chapter 1 Introduction This guide explains concepts and details to help you share FileMaker® data with other applications using ODBC (Open Database Connectivity) and JDBC (Java Database Connectivity). This guide also documents how the ODBC and JDBC client drivers, when used with FileMaker Pro and FileMaker Server Advanced, support the industry standards for ODBC, JDBC, and SQL (Structured Query Language).
FileMaker ODBC and JDBC Guide SQL is passed through the ODBC and JDBC interfaces to the FileMaker host of the data source, performing queries such as SELECT first_name, last_name FROM customers WHERE city='Paris' and making updates such as the creation of a new record with INSERT INTO customers (first_name, last_name) VALUES ('Jane','Smith').
Chapter 1 | Introduction 9 Updating files from previous versions Installing current drivers If you installed a driver from versions prior to FileMaker Server 9 Advanced or FileMaker Pro 9, you must uninstall the earlier driver and install the driver for version 10. For more information, see chapter 2, “Installing FileMaker ODBC and JDBC client drivers.” Note You have to create a DSN for each FileMaker database file you want to access as a data source.
FileMaker ODBC and JDBC Guide
Chapter 2 Installing FileMaker ODBC and JDBC client drivers These instructions help you install the drivers needed to access a FileMaker data source from third-party and custom applications via ODBC (Open Database Connectivity) and JDBC (Java Database Connectivity). The client drivers are available through a separate installation on your FileMaker CD or electronic download in the folder \xDBC. The latest versions of the client drivers are also available from www.filemaker.com/support/technologies.
FileMaker ODBC and JDBC Guide JDBC client driver requirements Applications using Require JDBC 1.22 API JDK 1.2 compatible Java Virtual Machine (JVM) JDBC 2.0 Core API JDK 1.3 compatible JVM JDBC 2.0 Optional Package JDK 1.3 compatible JVM Also, the following APIs are required and are supplied with SequeLink Java client: 1 JDBC 2.0 Optional Package 1 JNDI 1.2 1 JTA 1.0.1 JCA API JDK 1.3 JDBC 3.0 API JDK 1.4 or 1.
Chapter 2 | Installing FileMaker ODBC and JDBC client drivers 13 ODBC client driver installation (Mac OS) If you have previously installed the ODBC client driver for Mac OS, uninstall it before installing an updated version. To install the ODBC client driver: From the folder /xDBC/ODBC Client Driver Installer, copy the file SequeLink.bundle to either your System or User library. If you don’t have an /ODBC folder, create one manually: Library Copy SequeLink.
FileMaker ODBC and JDBC Guide 2. Click Next. Review the license agreement. 3. If the license agreement is acceptable, select I accept the terms of the license agreement, then click Next. A window of installation options appears. 4. Select Install Developer’s Tools. The tools include JDBCTest, which helps you verify your JDBC connections. 5. Enter an Install Directory. 1 Windows: Enter a path that includes your Java executable file (java.exe).
Chapter 3 Using ODBC to share FileMaker data Use the ODBC client driver to connect to a FileMaker data source from another application. The application that uses the ODBC client driver can directly access the data in a FileMaker database file. 1 Windows: The FileMaker ODBC client driver is DataDirect 32-BIT SequeLink 5.5. 1 Mac OS: The FileMaker ODBC client driver is ivslk20.dylib.
FileMaker ODBC and JDBC Guide Using the ODBC client driver You can use the ODBC client driver with any ODBC-compliant application.
Chapter 3 | Using ODBC to share FileMaker data 17 5. Construct and execute an SQL query in the client application. Each FileMaker database file that is open and set up for access is a separate data source (you create a DSN for each FileMaker database file you want to access as a data source). Each database can have one or more tables. FileMaker fields are represented as columns. The complete field name, including any non-alphanumeric characters, displays as the column name.
FileMaker ODBC and JDBC Guide 6. For Data Source Name, type a name that will be meaningful to others accessing the FileMaker data source. An additional Description is optional. Be sure Use LDAP is cleared. No translator .DLLs are included with the ODBC client driver (so clicking Translate will not allow you to configure an ODBC translator). 7. For SequeLink Server Host, enter the location of your data source.
Chapter 3 | Using ODBC to share FileMaker data 19 5. Click Test Connect. You are prompted to enter your FileMaker account name (in Database User Name) and password (in Database Password). If the connection is OK, you’ll receive the message Connection test was successful. If the connection fails: 1 Make sure the FileMaker database file is hosted and available. 1 Update or correct your connection information.
FileMaker ODBC and JDBC Guide Additionally, you’ll need to specify these keyword values for the DSN: Keyword Value Host If you’re connecting to a FileMaker database file hosted by FileMaker Pro on your local machine, type localhost (or 127.0.0.1). If you’re connecting to a FileMaker database file hosted by FileMaker Server Advanced over a network, type the IP address or hostname of FileMaker Server. Port Type 2399.
Chapter 4 Using JDBC to share FileMaker data If you’re a Java programmer, you can use the JDBC client driver with any Rapid Application Development (RAD) tool to visually create a Java application or applet that connects to a FileMaker data source. The Java application or applet that uses the JDBC client driver can directly access the data in a FileMaker database file. About JDBC JDBC is a Java API for executing SQL statements, the standard language for accessing relational databases.
1 1 1 1 1 1 1 1 FileMaker ODBC and JDBC Guide Holdable cursor support Making internal updates to the data in Blob and Clob objects Retrieving and updating the object referenced by a Ref object Updating of columns containing BLOB, CLOB, ARRAY and REF data types Boolean data type DATALINK data type Transform groups and type mapping Relationship between the JDBC SPI and the Connector architecture For additional details, see www.filemaker.com/support/technologies.
Chapter 4 | Using JDBC to share FileMaker data 2. Establishes a connection with the FileMaker data source (the JDBC URL is jdbc:sequelink:// 17.184.17.170:2399). 3. Returns error codes. import java.sql.*; class FMPJDBCTest { public static void main(String[ ] args) { // register the JDBC client driver try { Driver d = (Driver)Class.forName("com.ddtek.jdbc.sequelink.SequeLinkDriver").newInstance(); } catch(Exception e) { System.out.
FileMaker ODBC and JDBC Guide Specifying driver properties in the URL subname Specify the user and password driver properties in the subname of the JDBC URL. These are the properties that could be passed to the connection when calling the DriverManager.getConnection method via the Properties parameter.
Chapter 4 | Using JDBC to share FileMaker data 25 If your FileMaker database solution uses many FileMaker database files, create an additional database file that contains all the necessary external data source references, table occurrences, and relationships for your solution. Then define this additional database file as your data source in the JDBC URL. All of the FileMaker database files must be on the same computer. Note Secure Socket Layer (SSL) encryption is not supported.
FileMaker ODBC and JDBC Guide
Chapter 5 Supported standards This chapter describes the SQL statements and constructs supported by the FileMaker ODBC and JDBC client drivers. Use the client drivers to access a FileMaker database solution from an ODBC- or JDBCcompliant application. The FileMaker database solution can be hosted by either FileMaker Pro or FileMaker Server Advanced. The ODBC client driver supports ODBC 3.5 Level 1 with some features of Level 2. The JDBC client driver provides partial support for the JDBC 3.0 specification.
FileMaker ODBC and JDBC Guide The SELECT statement can use a variety of clauses: SELECT [DISTINCT] {* | column_expression [[AS] column_alias],...} FROM table_name [table_alias], ... [ WHERE expr1 rel_operator expr2 ] [ GROUP BY {column_expression, ...} ] [ HAVING expr1 rel_operator expr2 ] [ UNION [ALL] (SELECT...) ] [ ORDER BY {sort_expression [DESC | ASC]}, ... ] [ FOR UPDATE [OF {column_expression, ...}] ] Items in brackets are optional.
Chapter 5 | Supported standards 29 FROM clause The FROM clause indicates the tables that are used in the SELECT statement. The format is: FROM table_names [table_alias] table_names can be one or more simple table names in the current working directory or complete pathnames. table_alias can be used to give the table a more descriptive name, or to abbreviate a longer table name. Field names can be prefixed with the table name or the table alias.
FileMaker ODBC and JDBC Guide HAVING clause The HAVING clause enables you to specify conditions for groups of records (for example, display only the departments that have salaries totaling more than $200,000). This clause is valid only if you have already defined a GROUP BY clause. It has the following format: HAVING expr1 rel_operator expr2 expr1 and expr2 can be field names, constant values, or expressions. These expressions do not have to match a column expression in the SELECT clause.
Chapter 5 | Supported standards 31 column_expressions is a list of field names in the database table that you intend to update, separated by a comma. column_expressions is optional. The following example returns all records in the employee database that have a SALARY field value of more than $20,000. When each record is fetched, it is locked. If the record is updated or deleted, the lock is held until you commit the change. Otherwise, the lock is released when you fetch the next record.
FileMaker ODBC and JDBC Guide If file or JPEG data exists, the SELECT statement retrieves the data in binary form; otherwise, the SELECT statement returns . To retrieve file reference information from a container field, such as the file path to a file, picture, or Quicktime movie, use the CAST function with a SELECT statement.
Chapter 5 | Supported standards 33 DELETE statement Use the DELETE statement to delete records from a database table. The format of the DELETE statement is: DELETE FROM table_name [ WHERE { conditions } ] Note The WHERE clause determines which records are to be deleted. If you don’t include the WHERE keyword, all records in the table are deleted (but the table is left intact).
FileMaker ODBC and JDBC Guide In this type of INSERT statement, the number of columns to be inserted must match the number of columns in the SELECT statement. The list of columns to be inserted must correspond to the columns in the SELECT statement just as it would to a list of value expressions in the other type of INSERT statement. For example, the first column inserted corresponds to the first column selected; the second inserted to the second, and so on.
Chapter 5 | Supported standards 35 Examples Using Sample SQL text column CREATE TABLE T1 (C1 VARCHAR, C2 VARCHAR (50), C3 VARCHAR (1001), C4 VARCHAR (500276)) text column, NOT NULL CREATE TABLE T1NN (C1 VARCHAR NOT NULL, C2 VARCHAR (50) NOT NULL, C3 VARCHAR (1001) NOT NULL, C4 VARCHAR (500276) NOT NULL) numeric column CREATE TABLE T2 (C1 DECIMAL, C2 DECIMAL (10,0), C3 DECIMAL (7539,2), C4 DECIMAL (497925,301)) date column CREATE TABLE T3 (C1 DATE, C2 DATE, C3 DATE, C4 DATE) time column CREATE
FileMaker ODBC and JDBC Guide DROP INDEX statement Use the DROP INDEX statement to remove an index from a database file. The format of the DROP INDEX statement is: DROP INDEX [ON] table_name.column_name Remove an index when your database file is too large, or you don’t often use a field in queries. If your queries are experiencing poor performance, and you’re working with an extremely large FileMaker database file with many indexed text fields, consider dropping the indexes from some fields.
Chapter 5 | Supported standards 37 Examples SELECT SUM (Sales_Data.Amount) AS agg FROM Sales_Data SELECT AVG (Sales_Data.Amount) AS agg FROM Sales_Data SELECT COUNT (Sales_Data.Amount) AS agg FROM Sales_Data SELECT MAX (Sales_Data.Amount) AS agg FROM Sales_Data WHERE Sales_Data.Amount < 3000 SELECT MIN (Sales_Data.Amount) AS agg FROM Sales_Data WHERE Sales_Data.
FileMaker ODBC and JDBC Guide Constant Acceptable syntax (examples) Time TIME '14:35:10' { T '14:35:10' } {14:35:10} Timestamp TIMESTAMP '2005-06-05 14:35:10' { TS '2005-06-05 14:35:10'} { 06/05/2005 14:35:10 } {2005-06-05 14:35:10} { 06/05/05 14:35:10 } Make sure Strict data type: 4-Digit Year Date is not selected as a validation option in the FileMaker database file for a field using this 2-digit year syntax. When entering date and time values, match the format of the database file locale.
Chapter 5 | Supported standards 39 Date operators You can modify dates. Examples In the following examples, hire_date is {01/30/2004}.
FileMaker ODBC and JDBC Guide SELECT Sales_Data.Time_Sold FROM Sales_Data WHERE Sales_Data.Time_Sold < '12:00:00' SELECT Sales_Data.Company_Name FROM Sales_Data WHERE Sales_Data.Company_Name LIKE '%University' SELECT Sales_Data.Company_Name FROM Sales_Data WHERE Sales_Data.Company_Name NOT LIKE '%University' SELECT Sales_Data.Amount FROM Sales_Data WHERE Sales_Data.Amount IS NULL SELECT Sales_Data.Amount FROM Sales_Data WHERE Sales_Data.Amount IS NOT NULL SELECT Sales_Data.
Chapter 5 | Supported standards Functions The ODBC and JDBC client drivers support many functions you can use in expressions. Some of the functions return characters strings, some return numbers, and some return dates. Important Use uppercase letters for SQL function names (some are case sensitive).
FileMaker ODBC and JDBC Guide SELECT TIME() AS agg FROM Sales_Data WHERE Sales_Data.Invoice_ID = 1 SELECT USERNAME() AS agg FROM Sales_Data WHERE Sales_Data.
Chapter 5 Precedence Operator 6 Not 7 AND 8 OR | Supported standards 43 The following example shows the importance of precedence: WHERE salary > 40000 OR hire_date > {01/30/2004} AND dept = 'D101' Because AND is evaluated first, this query retrieves employees in department D101 hired after January 30, 2004, as well as every employee making more than $40,000, no matter what department or hire date.
FileMaker ODBC and JDBC Guide Reserved SQL keywords The following table lists reserved keywords that should not be used as names for columns, tables, aliases, or other user-defined objects. If you are getting syntax errors, these errors may be due to using one of these reserved words. If you want to use one of these keywords, you need to use quotation marks to prevent the word from being treated as a keyword.
FileMaker ODBC and JDBC Guide Reserved keywords NEXT NO NONE NOT NOW NULL NULLIF NUMERIC OBJECT OCTET_LENGTH OF OFF OID OLD ON ONLY OPEN OPERATION OPERATORS OPTION OR ORDER OTHERS OUTER OUTPUT OVERLAPS PAD PARAMETERS PARTIAL PENDANT POSITION POW POWER PRECISION PREORDER PREPARE PRESERVE PRIMARY PRIOR PRIVATE PRIVILEGES PROCEDURE PROTECTED PUBLIC RCASE READ REAL RECURSIVE REF REFERENCES REFERENCING RELATIVE REMOVE REPLACE RESIGNAL RESTRICT RETURN RETURNS REVOKE RIGHT ROLE ROLLBACK ROUND ROUTINE ROW ROW
FileMaker ODBC and JDBC Guide
Chapter 6 Mapping FileMaker fields to ODBC data types This table illustrates how FileMaker field types map to the standard ODBC data types. FileMaker field type Converts to ODBC data type About the data type text SQL_VARCHAR The maximum column length of text is 1 million characters, unless you specify a smaller Maximum number of characters for the text field in FileMaker. FileMaker returns empty strings as NULL.
FileMaker ODBC and JDBC Guide
Chapter 7 Mapping FileMaker fields to JDBC data types The JDBC client driver uses the following mappings when converting FileMaker data types to JDBC SQL types. (For information about these types, see the JDK 1.5 documentation web pages at www.javasoft.com.) FileMaker field type Converts to JDBC SQL type text java.sql.Types.VARCHAR number java.sql.Types.DOUBLE date java.sql.Types.DATE time java.sql.Types.TIME timestamp java.sql.Types.TIMESTAMP container java.sql.Types.
FileMaker ODBC and JDBC Guide
Chapter 8 ODBC and JDBC error messages Here are the basic formats of error messages you receive when working with FileMaker and ODBC/JDBC. For a listing of error numbers and explanations, see www.datadirect.com. For more information about working with errors in FileMaker, see the Get(LastError) or Get(LastODBCError) functions described in FileMaker Pro Help.
FileMaker ODBC and JDBC Guide SequeLink Server error messages An error reported by the SequeLink Server has the following format: [DataDirect] [ODBC SequeLink driver] [SequeLink Server] message For example: [DataDirect] [ODBC SequeLink driver] [SequeLink Server] Only SELECT statements are allowed in this read-only connection.
Chapter 8 | ODBC and JDBC error messages 53 Data source error messages An error that occurs in the data source includes the data source name, in the following format: [DataDirect] [SequeLink JDBC Driver] [data_source] message For example, you might get the following message from your FileMaker data source: [DataDirect] [SequeLink JDBC Driver] [FileMaker] Invalid Username/Password If you get this type of error, you did something incorrectly with the database system.
FileMaker ODBC and JDBC Guide
Index A Access via ODBC/JDBC extended privilege 16 accounts and privileges 16 aggregate functions in SQL 36 aliases with SELECT statement 28, 31 ALL operator 39 ALTER TABLE (SQL statement) 35 AND operator 40 ANY operator 39 APIs 7 ARRAY data type 22 auto-generated keys 21 B B function 42 BETWEEN operator 39 bitmap files in container fields 32 blank characters 38 blank space in database name 20, 24 blank value in columns 33 BLOB data type JDBC limitation 22 use in CREATE TABLE 35 use in SELECT 31 Boolean da
FileMaker ODBC and JDBC Guide DSNs creating (Mac OS) 19 creating (Windows) 17 keyword values for (Mac OS) 20 one per file 9 FileMaker JDBC client drivers 13 FileMaker ODBC client drivers 12 INT function 42 E JAR archive files 13 Java Development Kit (JDK) 22 Java version 12 JDBC client driver, described 21 described 21 error messages 52 overview of using 7 JDBC client driver driver class and main entry point 22 installing 13 mapping data types 49 meta data functions 43 registering with the JDBC driv
| ODBC client driver requirements 11 mapping data types JDBC client driver 49 ODBC client driver 47 MAX function 42 meta data functions for JDBC 43 Microsoft Access client application 8 Microsoft Query Wizard 8 MIN function 42 MOD function 42 MONTH function 42 P N Q network requirements 8 NOT NULL (SQL clause) 34 NOT operator 40 null value 33, 47 numeric operators in SQL expressions 38 NUMVAL function 42 QuickTime files in container fields 32 O ODBC described 15 error messages 51 overview of using 7 r
FileMaker ODBC and JDBC Guide functions 41 literals 37 logical operators 40 numeric operators 38 operator precedence 42 relational operators 39 SQL standards compliance 27 SQL statements ALTER TABLE 35 CREATE INDEX 35 CREATE TABLE 34 DELETE 33 DROP INDEX 36 INSERT 33 reserved keywords 44 SELECT 27 supported by client drivers 27 UPDATE 34 SQL_C_BINARY data type 27 SQL_C_WCHAR data type 27 SQL-92 27 SQLExceptions 52 standards compliance 27 string functions 41 STRVAL function 41 subqueries 33 SUBSTR funct