FileMaker 9 ® ODBC and JDBC Guide
© 2004-2007 FileMaker, Inc. All Rights Reserved. FileMaker, Inc. 5201 Patrick Henry Drive Santa Clara, California 95054 FileMaker is a trademark of FileMaker, Inc., registered in the U.S. and other countries, and ScriptMaker and the file folder logo are trademarks of FileMaker, Inc. 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 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 requirements Networkin
FileMaker ODBC and JDBC Guide Chapter 4 Using JDBC to share FileMaker data About JDBC 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 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 U
| Contents 5 Appendix A Mapping FileMaker fields to ODBC data types 47 Appendix B Mapping FileMaker fields to JDBC data types 49 Appendix C 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 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 If you used LDAC (Local Data Access Companion) or RDAC (Remote Data Access Companion) in versions prior to FileMaker Server 5.5 to share a database file, you’ll need to make two changes. First, you need to set up users to belong to an account that has the extended privilege of Access via ODBC/JDBC (as part of the account’s privilege set).
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 6. Click Next. 7. Confirm your installation selections, then click Install. 8. When the installation is complete, click Finish. The JDBC client driver is now available for you to configure for accessing a FileMaker data source. Configuring client drivers Before using a client application to access a FileMaker data source, you must configure a client driver for the data source.
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 1 Windows: The FileMaker ODBC client driver is DataDirect 32-BIT SequeLink 5.5. 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 Accessing a FileMaker database file from a Windows application Specifying ODBC client driver properties for a FileMaker DSN (Windows) Create a DSN for each FileMaker database file you want to access as a data source. The DSN identifies the FileMaker ODBC client driver, the location of the FileMaker host application, and the FileMaker database file you’re accessing as a data source. To set up or change ODBC client driver properties: 1.
FileMaker ODBC and JDBC Guide 10. If you’ve enabled sharing via ODBC/JDBC in the host application, click the button to the right of Server Data Source to display the filenames of currently open FileMaker database files for you to choose from. If your database name contains spaces, replace them with the escape characters %20. For example, serverdatasource=MY%20DATABASE. 11. Click OK to save your data source information.
Chapter 3 | Using ODBC to share FileMaker data 19 Accessing a FileMaker database file from a Mac OS application If you build custom applications, use version 3.52.1 of the ODBC headers and libraries. Applications built with version 3.51 might not be able to load the client driver. Configuring the ODBC client driver (Mac OS) Configure the client driver using the ODBC Administrator bundled with the ODBC driver manager software recommended for your client application.
FileMaker ODBC and JDBC Guide
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.
FileMaker ODBC and JDBC Guide About the JDBC client driver The JDBC client driver provides partial support for the JDBC 3.0 specification.
Chapter 4 | Using JDBC to share FileMaker data Registering the JDBC client driver and connecting to a FileMaker data source (an example) Here is a snippet of a JDBC client application that: 1. Registers the JDBC client driver with the JDBC driver manager. 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.
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 JDBC URL connection with the database name, user name, and password specified in the URL Format 1 (using the data store user name and password): jdbc:sequelink://:;serverDataSource=;DBUser=; DBPassword= Format 2 (using the host user name and password): jdbc:sequelink://:;serverDataSource=;HUser=;HPassword=
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 FOR UPDATE clause The FOR UPDATE clause performs Positioned Updates or Positioned Deletes via SQL cursors. The format is: FOR UPDATE [OF column_expressions] 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.
FileMaker ODBC and JDBC Guide Retrieving the contents of a container field: CAST() function and GetAs() function You can retrieve binary data, file reference information, or data of a specific file type from a container field. To retrieve binary data, use a standard SELECT statement. For example: SELECT Company_Brochures FROM Sales_Data If file or JPEG data exists, the SELECT statement retrieves the data in binary form; otherwise, the SELECT statement returns .
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 The SELECT statement is a query that returns values for each column_name value specified in the column name list. Using a SELECT statement instead of a list of value expressions lets you select a set of rows from one table and insert it into another table using a single INSERT statement.
Chapter 5 | Supported standards 35 CREATE TABLE statement Use the CREATE TABLE statement to create a table in a database file. The format of the CREATE TABLE statement is: CREATE TABLE table_name table_element_list [NOT NULL] Within the statement, you specify the name and data type of each column. table_name and table_element_list have a 100 character limit.
FileMaker ODBC and JDBC Guide CREATE INDEX statement Use the CREATE INDEX statement to speed searches in your database file. The format of the CREATE INDEX statement is: CREATE INDEX [ index_name ][ON] table_name.column_name CREATE INDEX is supported for a single column (multi-column indexes are not supported).
Chapter 5 | Supported standards 37 Aggregate function Returns SUM The total of the values in a numeric field expression. For example, SUM(SALARY) returns the sum of all salary field values. AVG The average of the values in a numeric field expression. For example, AVG(SALARY) returns the average of all salary field values. COUNT The number of values in any field expression. For example, COUNT(NAME) returns the number of name values.
FileMaker ODBC and JDBC Guide You must enclose date, time, and timestamp constants in braces ({}), for example, {D '2005-06-05'}, {14:35:10}, and {TS '2005-06-05 14:35:10'}. The one exception: SQL-92 syntax requires ISO date and time formats with no brackets: 1 1 1 DATE 'YYYY-MM-DD' TIME 'HH:MM:SS' TIMESTAMP 'YYYY-MM-DD HH:MM:SS' Constant Acceptable syntax (examples) Text 'Paris' Number 1.
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 41 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 SPACE(2) + Salespeople.Salesperson_ID AS Salesperson_ID FROM Salespeople SELECT STRVAL('60506') AS agg FROM Sales_Data WHERE Sales_Data.Invoice_ID = 1 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 | Supported standards 43 Operator precedence As expressions become more complex, the order in which the expressions are evaluated becomes important. This table shows the order in which the operators are evaluated. The operators in the first line are evaluated first, and so on. Operators in the same line are evaluated left to right in the expression.
FileMaker ODBC and JDBC Guide JDBC Meta Data functions The JDBC client driver supports the following Meta Data functions: 1 1 1 1 1 1 getColumns getColumnPrivileges getMetaData getTypeInfo getTables getTableTypes 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.
FileMaker ODBC and JDBC Guide Reserved keywords IF IFNULL IGNORE IMMEDIATE IN INDEX INDICATOR INITIALLY INNER INPUT INSENSITIVE INSERT INT INTEGER INTERSECT INTERVAL INTO IS ISOLATION JOIN KEY LANGUAGE LAST LCASE LEADING LEAVE LEFT LEN LENGTH LESS LEVEL LIKE LIMIT LOCAL LOOP LOWER LTRIM MATCH MAX MIN MINUTE MOD MODIFY MODULE MONTH NAMES NATIONAL NATURAL NCHAR NEW 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 OU
FileMaker ODBC and JDBC Guide
Appendix A 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 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
Appendix B 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
Appendix C 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.
Appendix C | 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 Access, Microsoft.
FileMaker ODBC and JDBC Guide drivers installing FileMaker JDBC 13 installing FileMaker ODBC 12 uninstalling old 9 DROP INDEX (SQL statement) 36 DSNs creating (Mac OS) 19 creating (Windows) 17 keyword values for (Mac OS) 19 one per file 9 I E J error message formats 51 escape character 19, 24 EXISTS operator 39 exponential notation in SQL expressions 38 expressions in SQL 37 extended privileges 16 JAR archive files 13 Java Development Kit (JDK) 22 Java version 12 JDBC client driver, described 22 d
| M Mac OS creating a DSN 19 installing JDBC client driver 13 installing ODBC client driver 13 JDBC client driver requirements 12 ODBC Administrator 19 ODBC client driver requirements 11 mapping data types JDBC client driver 49 ODBC client driver 47 MAX function 42 meta data functions for JDBC 44 Microsoft Access client application 8 importing fields into 16 Microsoft Query Wizard 8 MIN function 42 MOD function 42 MONTH function 42 Index OR operator 40 ORDER BY (SQL clause) 30 OUTER JOIN 29 overview sett
FileMaker ODBC and JDBC Guide SPACE function 41 space in database name 19, 24 SQL aggregate functions 36 SQL expressions 37 character operators 38 constants 37 date operators 39 exponential or scientific notation 38 field names 37 functions 41 literals 37 logical operators 40 numeric operators 38 operator precedence 43 relational operators 39 SQL standards compliance 27 SQL statements ALTER TABLE 35 CREATE INDEX 36 CREATE TABLE 35 DELETE 33 DROP INDEX 36 INSERT 33 reserved keywords 44 SELECT 27 support