Components of a JDBC connection

How a JDBC connection is made

In PowerBuilder when you access a database through the JDBC interface, your connection goes through several layers before reaching the database. It is important to understand that each layer represents a separate component of the connection, and that each component might come from a different vendor.

Because JDBC is a standard API, PowerBuilder uses the same interface to access every JDBC-compliant database driver.

Figure 3-1 shows the general components of a JDBC connection.

Figure 3-1: Components of a JDBC connection

The figure shows the components of a JDBC connection. At top is the Development environment. It is connected to the Database interface D L L called P B J D B n 0 dot D L L, which is supplied by Sybase. The Database interface D L L is connected to the Java Virtual Machine, shown here as the Sun Java Runtime Environment supplied by Sybase or Sun. This is connected to a JDBC driver such as Sybase j Connect. The driver is supplied by a database vendor. The driver connects to the database.

The JDBC DLL

PowerBuilder provides the pbjdb125.dll. This DLL runs with the Sun Java Runtime Environment (JRE) versions 1.1 and later.

PowerBuilder Java package

PowerBuilder includes a small package of Java classes that gives the JDBC interface the level of error-checking and efficiency (SQLException catching) found in other PowerBuilder interfaces. The package is called pbjdbc12125.jar and is found in Sybase\Shared\PowerBuilder.

The Java Virtual Machine

The Java Virtual Machine (JVM) is a component of Java development software. When you install PowerBuilder, the Sun Java Development Kit (JDK), including the Java Runtime Environment (JRE), is installed on your system in Sybase\Shared\PowerBuilder. For PowerBuilder 12.5, JDK 1.5 is installed. This version of the JVM is started when you use a JDBC connection or any other process that requires a JVM and is used throughout the PowerBuilder session.

If you need to use a different JVM, see the instructions in “Preparing to use the JDBC interface”. For more information about how the JVM is started, see the chapter on deploying your application in Application Techniques.

The JDBC drivers

The JDBC interface can communicate with any JDBC-compliant driver including Sybase jConnect™ for JDBC (available with Sybase ASE, IQ, and SA database clients) and the Oracle and IBM Informix JDBC drivers. These drivers are native-protocol, all-Java drivers—that is, they convert JDBC calls into the SQL syntax supported by the databases.

Accessing Unicode data

Using the ODBC interface, PowerBuilder can connect, save, and retrieve data in both ANSI/DBCS and Unicode databases but does not convert data between Unicode and ANSI/DBCS. When character data or command text is sent to the database, PowerBuilder sends a Unicode string. The driver must guarantee that the data is saved as Unicode data correctly. When PowerBuilder retrieves character data, it assumes the data is Unicode.

A Unicode database is a database whose character set is set to a Unicode format, such as UTF-8, UTF-16, UCS-2, or UCS-4. All data must be in Unicode format, and any data saved to the database must be converted to Unicode data implicitly or explicitly.

A database that uses ANSI (or DBCS) as its character set might use special datatypes to store Unicode data. Columns with these datatypes can store only Unicode data. Any data saved into such a column must be converted to Unicode explicitly. This conversion must be handled by the database server or client.