skip to main content
Using the driver : Statement Pool Monitor : Importing statements into a statement pool
  

Try DataDirect Drivers Now

Importing statements into a statement pool

When importing statements into a statement pool, for each statement entry in the export file, a statement is added to the statement pool provided a statement with the same SQL text and statement attributes does not already exist in the statement pool. Existing statements in the pool that correspond to a statement entry are kept in the pool unless the addition of new statements causes the number of statements to exceed the maximum pool size. In this case, the driver closes and discards some statements until the pool size is shrunk to the maximum pool size.
For example, if the maximum number of statements allowed for a statement pool is 10 and the number of statements to be imported is 20, only the last 10 imported statements are placed in the statement pool. The other statements are created, closed, and discarded. Importing more statements than the maximum number of statements allowed in the statement pool can negatively affect performance because the driver unnecessarily creates some statements that are never placed in the pool.
To import statements into a statement pool:
1. Create a statement pool export file. See "Statement pool export file example" for an example of a statement pool export file.
Note: The easiest way to create a statement pool export file is to generate an export file from the statement pool associated with the connection as described in "Generating a statement pool export file."
2. Edit the export file to contain statements to be added to the statement pool.
3. Import the contents of the export file to the statement pool using either of the following methods to specify the path and file name of the export file:
*Use the ImportStatementPool property. For example:
jdbc:datadirect:sqlserver://MyServer:1433;
User=User123;Password=secret;
DatabaseName=MyDB;
ImportStatementPool=C:\\statement_pooling\\stmt_export.txt
*Use the importStatements() method of the ExtStatementPoolMonitorMBean interface. For example:
ExtStatementPoolMonitor monitor =
   ((ExtConnection)
con).getStatementPoolMonitor().importStatements
   ("C:\\statement_pooling\\stmt_export.txt");