Issue Details (XML | Word | Printable)

Key: DERBY-3779
Type: Task Task
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Kim Haase
Reporter: Kristian Waagan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Add client side JDBC statement pool documentation

Created: 10/Jul/08 09:54 AM   Updated: 04/May/09 06:22 PM
Return to search
Component/s: Documentation
Affects Version/s: 10.4.2.0, 10.5.1.1
Fix Version/s: 10.4.2.0, 10.5.1.1

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works DERBY-3779-2.diff 2008-07-31 02:59 PM Kim Haase 8 kB
Zip Archive Licensed for inclusion in ASF works DERBY-3779-2.zip 2008-07-31 02:59 PM Kim Haase 5 kB
File Licensed for inclusion in ASF works DERBY-3779.diff 2008-07-25 03:21 PM Kim Haase 8 kB
File Licensed for inclusion in ASF works DERBY-3779.stat 2008-07-25 03:21 PM Kim Haase 0.1 kB
Zip Archive Licensed for inclusion in ASF works DERBY-3779.zip 2008-07-25 03:21 PM Kim Haase 5 kB
Issue Links:
Reference
 

Resolution Date: 01/Aug/08 01:46 PM


 Description  « Hide
Document the new feature client side JDBC statement cache in the manual(s).

As a starter, see DERBY-3313 and the package.html file (or browse it from the Subversion repository).

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kim Haase added a comment - 22/Jul/08 09:20 PM
The only user-visible API change for this feature seems to be the addition of the maxStatements property to ClientConnectionPoolDataSource. Is that correct?

I would expect this feature also to work for ClientConnectionPoolDataSource40, though I don't see any explicit statement to this effect in DERBY-3313 or its subtasks (I might have missed it, though). Is that true?

I assume that a developer must use these data sources in order to use statement caching.

The package.html file has sample code that does the following (comments removed):

ClientConnectionPoolDataSource cpds = new ClientConnectionPoolDataSource();
cpds.setMaxStatements(20);
PooledConnection pc = cpds.getPooledConnection();

I'm assuming that you'd also have to set various other connection properties before calling getPooledConnection().

This new feature belongs in the Admin Guide, since that is where the client driver is discussed. (The Developer's Guide deals almost entirely with the embedded driver.) The information should probably be added to cadminnsdatasources.dita (Accessing the Network Server by using a DataSource), and another example should be added to the subtopic radminnsdatasourcexmp.dita (DataSource access example) showing the use of the statement cache. Does this make sense? I'll see if there are other places where it would make sense to mention statement caching.

Kristian Waagan added a comment - 23/Jul/08 06:17 AM
Kim, thanks for looking at this. See my comments below.

-----
The only user-visible API change for this feature seems to be the addition of the maxStatements property to ClientConnectionPoolDataSource. Is that correct?
-----
Yes, and it is also true for ClientConnectionPoolDataSource40.

------
I assume that a developer must use these data sources in order to use statement caching.
-----
Correct.

-----
I'm assuming that you'd also have to set various other connection properties before calling getPooledConnection().
----
Yes, you also have to set whatever other properties you need to connect to your database. getPooledConnection creates the physical connection to the database, PooledConnection.getConnection() creates a logical connection. The typical usage is that you create many logical connections off the physical one, but only one can be active at any given time. Also, as soon as a new logical connection is created, the previous one is closed.

-----
This new feature belongs in the Admin Guide, since that is where the client driver is discussed.
-----
That makes sense, currently the feature is for the client driver only.

A user will (transparently) interact with the cache through Connection.prepareStatement/-Call and PreparedStatement/CallableStatement.close. The former possibly takes a statement out of the cache, the latter possibly puts a statement into the cache.

Kim Haase added a comment - 25/Jul/08 03:21 PM
Thanks for your help confirming what needs to be covered here, Kristiaan.

I'm attaching DERBY-3779.diff, DERBY-3779.zip, and DERBY-3779.stat. I modified the files src/adminguide/cadminnsdatasources.dita and src/adminguide/radminnsdatasourcexmp.dita to document statement caching, I hope correctly. I included all the information about user-visible aspects but left out implementation details. Please let me know if any changes are needed.

Kristian Waagan added a comment - 31/Jul/08 09:36 AM
I think the documentation looks good.
The following sentence caught my attention though:
"Next, use a javax.sql.PooledConnection object to obtain a physical connection, and a javax.sql.Connection object to obtain a logical connection."

You use ClientConnectionPoolDataSource.getPooledConnection to obtain the physical connection, the PooledConnection object is the physical connection. Then you use PooledConnection.getConnection to obtain the logical connection, which will implement java.sql.Connection just as a "normal" connection would. Do you see a way to rewrite the sentence?
The piece of information that you need to use getPooledConnection is important, because I think Derby has a getConnection method on the ClientConnectionPoolDataSource object. Using the latter method will not enable statement caching.

BTW; PooledConnection is in the package javax.sql, whereas Connection is in java.sql.


Thanks,

Kim Haase added a comment - 31/Jul/08 02:59 PM
Thanks very much, Kristiaan, for catching those things. I hope this patch fixes them. I'm attaching DERBY-3779-2.diff and DERBY-3779-2.zip.

I also put the steps in a numbered list to make them clearer, added a link to the example, and fixed the vertical spacing at the top of the example (the problem only showed up in the PDF and one-file HTML).

Kristian Waagan added a comment - 01/Aug/08 09:04 AM
Revision 2 of the patch looks good, Kim.
+1 to commit.

Kim Haase added a comment - 01/Aug/08 01:41 PM
Thanks very much, Kristiaan.

Committed patch DERBY-3779-2.diff to docs trunk at revision 681687.

Merged to 10.4 branch at revision 681689.

Kim Haase added a comment - 01/Oct/08 07:51 PM
Changes appear in both Latest Alpha Manuals and in the 10.4 documentation, so this issue can be closed.