Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Creating an Internal Connection Pool (ELUG)"

m (New page: <div style="float:right;border:1px solid #000000;padding:5px">__TOC__ Related Topics</div> This section explains how t...)
 
m
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
[[Image:Elug draft icon.png]] '''For the latest EclipseLink documentation, please see http://www.eclipse.org/eclipselink/documentation/ '''
 +
 +
----
 
<div style="float:right;border:1px solid #000000;padding:5px">__TOC__
 
<div style="float:right;border:1px solid #000000;padding:5px">__TOC__
 
[[Special:Whatlinkshere/Creating an Internal Connection Pool (ELUG)|Related Topics]]</div>
 
[[Special:Whatlinkshere/Creating an Internal Connection Pool (ELUG)|Related Topics]]</div>
This section explains how to create EclipseLink internal connection pools.
 
  
 
For information, see [[Introduction%20to%20Data%20Access%20(ELUG)#Internal Connection Pools|Internal Connection Pools]].
 
For information, see [[Introduction%20to%20Data%20Access%20(ELUG)#Internal Connection Pools|Internal Connection Pools]].
 
  
  
Line 16: Line 17:
  
 
After you create and configure a named connection pool, you use it in your application by passing in a <tt>ConnectionPolicy</tt> when you acquire a client session (see [[Acquiring%20and%20Using%20Sessions%20at%20Run%20Time%20(ELUG)#How to Acquire a Client Session that Uses a Named Connection Pool|How to Acquire a Client Session that Uses a Named Connection Pool]]).
 
After you create and configure a named connection pool, you use it in your application by passing in a <tt>ConnectionPolicy</tt> when you acquire a client session (see [[Acquiring%20and%20Using%20Sessions%20at%20Run%20Time%20(ELUG)#How to Acquire a Client Session that Uses a Named Connection Pool|How to Acquire a Client Session that Uses a Named Connection Pool]]).
 +
  
 
==Creating an Internal Connection Pool==
 
==Creating an Internal Connection Pool==
Line 22: Line 24:
  
 
Alternatively, you can create internal connection pools in Java. For more information on creating sessions in Java, see the ''EclipseLink API Reference.
 
Alternatively, you can create internal connection pools in Java. For more information on creating sessions in Java, see the ''EclipseLink API Reference.
 
  
  
Line 35: Line 36:
 
#* To create a named connection pool, select '''Create a New Named Connection Pool''', enter a name, and click '''OK'''.
 
#* To create a named connection pool, select '''Create a New Named Connection Pool''', enter a name, and click '''OK'''.
 
#* To create a sequence connection pool, select '''Add the Sequence Connection Pool'''.
 
#* 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 context menu.
+
#* 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 context menu.
 +
 
 +
 
 +
===How to Create an Internal Connection Pool Using Java===
 +
Using Java, you can create read, write, and named connection pools.
 +
The [[#Example:Creating Connection Pools|Creating Connection Pools example]] shows how to create connection pools. The [[#Example:Using a Single Pool for Read and Write|Using a Single Pool for Read and Write example]] shows an optimized connection pool, using the same connetion for both read and write operations.
 +
 
 +
<span id="Example:Creating Connection Pools"></span>
 +
''''' 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);
 +
 
 +
 
 +
<span id="Using a Single Pool for Read and Write"></span>
 +
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
 +
 
 +
''''' Using a Single Pool for Read and Write'''''
 +
ConnectionPool pool = new ConnectionPool();
 +
pool.setName("default");
 +
pool.setLogin(login);
 +
pool.setMaxNumberOfConnections(50);
 +
pool.setMinNumberOfConnections(50);
 +
serverSession.setReadConnectionPool(pool);
 +
serverSession.addConnectionPool(pool);
  
  
Line 43: Line 90:
  
 
[[Category: EclipseLink User's Guide]]
 
[[Category: EclipseLink User's Guide]]
[[Category: Draft]]
+
[[Category: Release 1]]
 
[[Category: Task]]
 
[[Category: Task]]

Latest revision as of 11:14, 23 July 2012

Elug draft icon.png For the latest EclipseLink documentation, please see http://www.eclipse.org/eclipselink/documentation/


For information, see Internal Connection Pools.


Introduction to the Internal Connection Pool Creation

You can create internal connection pools only for server sessions (not for any other session type, including database sessions). For more information, see Creating an Internal Connection Pool.

After you create an internal connection pool, you must configure its various options.

After you create and configure a sequence connection pool, EclipseLink uses it whenever it needs to assign an identifier to a new object.

After you create and configure a named connection pool, you use it in your application by passing in a ConnectionPolicy when you acquire a client session (see How to Acquire a Client Session that Uses a Named Connection Pool).


Creating an Internal Connection Pool

You can create an internal connection pool using the Workbench (see How to Create an Internal Connection Pool Using Workbench) or Java code. We recommend that you use the Workbench to create and manage your internal connection pools.

Alternatively, you can create internal connection pools in Java. For more information on creating sessions in Java, see the EclipseLink API Reference.


How to Create an Internal Connection Pool Using Workbench

Before you create a connection pool, you must first create a server session (see Creating a Server Session).

To create a new EclipseLink internal connection pool, use this procedure:

  1. Select the server session in the Navigator in which you want to create a connection pool.
  2. Create New Sequence Connection Pool button 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 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 context menu.


How to Create an Internal Connection Pool Using Java

Using Java, you can create read, write, and named connection pools. The Creating Connection Pools example shows how to create connection pools. The Using a Single Pool for Read and Write example shows an optimized connection pool, using the same connetion for both read and write operations.

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

Using a Single Pool for Read and Write

ConnectionPool pool = new ConnectionPool();
pool.setName("default");
pool.setLogin(login);
pool.setMaxNumberOfConnections(50);
pool.setMinNumberOfConnections(50);
serverSession.setReadConnectionPool(pool);
serverSession.addConnectionPool(pool);



Copyright Statement

Back to the top