This chapter explains how to create TopLink internal connection pools.
This chapter includes the following sections:
You can create internal connection pools (see Section 96.1.6.1, "Internal Connection Pools") only for server sessions. For more information, see Section 100.2, "Creating an Internal Connection Pool"
.
After you create an internal connection pool, you must configure its various options (see Chapter 101, "Configuring an Internal Connection Pool")
After you create and configure a sequence connection pool (see Section 96.1.6.4, "Sequence Connection Pools"), TopLink will use this pool whenever it needs to assign an identifier to a new object.
After you create and configure a named connection pool (see Section 96.1.6.5, "Application-Specific Connection Pools"), you use it in your application by passing in a
ConnectionPolicy
when you acquire a client session (see Section 90.4.4, "How to Acquire a Client Session that Uses a Named Connection Pool").
You can create an internal connection pool using Oracle JDeveloper, TopLink Workbench, or Java code.
Before you create a connection pool, you must first create a server session (see Section 88.4, "Creating a Server Session").
To create a new TopLink internal connection pool, use this procedure:
Select the server session in the Navigator in which you want to create a connection pool.
Click the appropriate button on the toolbar to create the type of connection pool you want:
To create a named connection pool, select Create a New Named Connection Pool, enter a name, and then click OK.
To create a sequence connection pool, select Add the Sequence Connection Pool.
To create a write connection pool, select Add the Write Connection Pool.
You can also create a new internal connection pool by right-clicking the server session configuration in the Navigator and selecting New > Named Connection Pool, Sequence Connection Pool, or Write Connection Pool from the menu.
Using Java, you can create read, write, and named connection pools.
Example 100-1 shows how to create connection pools. Example 100-2
shows an optimized connection pool, using the same connection for both read and write operations.
Example 100-1 Creating Connection Pools
// Read ConnectionPool pool = new ConnectionPool(); pool.setName("read"); pool.setLogin(login); pool.setMaxNumberOfConnections(50); pool.setMinNumberOfConnections(50); serverSession.setReadConnectionPool(pool); // Write ConnectionPool pool = new ConnectionPool(); pool.setName("default"); pool.setLogin(login); pool.setMaxNumberOfConnections(50); pool.setMinNumberOfConnections(50); serverSession.addConnectionPool(pool); // Named ConnectionPool pool = new ConnectionPool(); pool.setName("admin"); pool.setLogin(login); pool.setMaxNumberOfConnections(2); pool.setMinNumberOfConnections(2); serverSession.addConnectionPool(pool);
You can also use a single connection pools for both read and write operations, when the read and write pools use the same login information. This method requires fewer connections