Chapter 4
|
Using JDBC to share FileMaker data 23
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.*;
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.println(e);
}
// establish a connection to FileMaker
Connection con;
try {
con =
DriverManager.getConnction(“jdbc:sequelink://17.184.17.170:2399;
user=some user;password=some password;serverDataSource=database”);
} catch(Exception e) + ";serverdatasource=" + dbName{
System.out.println(e);
}
// get connection warnings + ";serverDataSource=" + dbName
SQLWarning warning = null;
try {
warning = con.getWarnings();
if (warning == null) {
System.out.println("No warnings");
return;
}
while (warning != null) {
System.out.println("Warning: "+warning);
warning = warning.getNextWarning();
}
} catch (Exception e) {
Sysem.out.println(e);
}
}
}þ
Note This example is not meant to be compiled.