For further information about SQL, consult the documentation of your database management system.
You can connect to a data source in four easy steps. Refer to the sample code at the end of these steps for more details.
1. Load and register the driver with the JDBC Driver Manager.
The database URL specifies which data source you want to connect with. The format of a database URL is:
jdbc:simba://<server name>:<server port>/<data source name>
Table 1: Database URL parameters |
3. Create and set the connection properties.
Properties may simply be the user name and password or more detailed properties for more advanced database configurations. For a list of advanced properties that can be set for DBIntegrator Server, see Table 2, "DBIntegrator Server Properties", and see Table 3, "DBIntegrator Client 'Encoding' Property" for a property used by DBIntegrator Client.
4. Call DriverManager.getConnection
DriverManager.getConnection specifies the URL and any data source-specific properties and DBIntegrator Server-specific connection properties.
The following table lists the DBIntegrator Server-specific
properties.
Table 2: DBIntegrator Server Properties |
Connection Property | Description |
Encoding | Specifies the character encoding used by the data source. See the detailed description which follows this table. |
Table 3: DBIntegrator Client 'Encoding' Property |
The 'Encoding' connection property allows you to access a database which uses a different character encoding than the system the JDBC driver is running on. For instance, when accessing a UTF-8 (Unicode) database, you may need to set 'Encoding' to 'UTF8'. Failure to correctly set this property when required can result in corrupted character (string) data.
By default, the JDBC driver uses the system encoding used by the platform on which the driver is running. In other words, if the 'Encoding' property is not set, the platform's system encoding is used.
For example, if the driver is running on English Windows it assumes all string data from the data source consists of only ASCII characters. If this is not the case, the driver will fail to fetch strings correctly unless 'Encoding' is set to indicate the encoding actually being used by the data source. The JDBC driver must convert fetched strings to Unicode because the Java internal string data type is Unicode. Back to the example, if the fetched strings are not ASCII, the converted strings are likely to be corrupted.
You can specify any Java encoding name (see the Canonical Names listed on the web page at the URL given below) that matches the character set of the database. For example, you can use 'UTF8' for a UTF-8 database, or 'EUC_JP' for a Japanese EUC database.
For details regarding Supported Encodings for Java, please see: http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html.
This code would load and register the driver, configure the driver and then connect to the database.
m_Connection.clearWarnings();
Copyright © 1998-9, 2002, Unify Corporation. All rights reserved.