Bug 42018 - JDBC Sampler always commits
Summary: JDBC Sampler always commits
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.2
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-02 03:31 UTC by Karl Griesser
Modified: 2007-05-02 16:36 UTC (History)
0 users



Attachments
set auto-commit configuration parameter at the same level as pool-controller (1.12 KB, patch)
2007-04-24 23:49 UTC, Rubén Laguna
Details | Diff
add the possibility of issuing commit and rollback toward the database (5.65 KB, patch)
2007-04-25 01:27 UTC, Rubén Laguna
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Karl Griesser 2007-04-02 03:31:37 UTC
I have a "JDBC Connection Configuration" with autocommit=false.
There are various JDBC Requests using this connection configuration.

I've done some database traces and it looks like every JDBC request is commited.
So the autocommit parameter on the "JDBC Connection Configuration" has no effect
on the commit behaviour of the "JDBC Request".
Comment 1 Rubén Laguna 2007-04-24 23:49:00 UTC
Created attachment 20035 [details]
set auto-commit configuration parameter at the same level as pool-controller

I've checked this and you are right. There is a bug on the
DataSourceElement.java . The code tries to se the "auto-commit" attribute as
part of pool-controller but auto-commit doesn't belong to pool-controller it
should be a sibling of pool-controller. This becomes clear taking a look to the
excalibur-datasource-1.1.1.jar source code ResourceLimitingJdbcDataSource.java
, more precisely the lines
*** final Configuration controller = configuration.getChild( "pool-controller"
);

*** final boolean autoCommit = configuration.getChild( "auto-commit"
).getValueAsBoolean( true );

Looking at those lines is evident that pool-controller and auto-commit are
siblings and auto-commit shouldn't be added as a child of pool-controller

I'm providing a patch attached that solves the issue.
Comment 2 Rubén Laguna 2007-04-25 00:32:49 UTC
(In reply to comment #1)

By the way, Is there any possibility of replacing the excalibur connection
pooling with more popular solutions as proposed in
http://wiki.apache.org/jakarta-jmeter/Java14Proposals?




Comment 3 Rubén Laguna 2007-04-25 01:27:31 UTC
Created attachment 20036 [details]
add the possibility of issuing commit and rollback toward the database

If you set autocommit to false, it becomes imposible to issue commit and
rollback instructions at least to databases that doesn't support COMMIT and
ROLLBACK as statements. Those database require you to use conn.commit() and
conn.rollback() instead. With this patch you can write commit or rollback in a
JDBC Request and the JDBC Sampler will translate it to the correct .commit() or
rollback() call.
Comment 4 Rubén Laguna 2007-04-25 01:38:09 UTC
(In reply to comment #3)
> rollback instructions at least to databases that doesn't support COMMIT and
> ROLLBACK as statements. Those database require you to use conn.commit() and
> 

I'm talking about databases like Apache Derby here. The Derby JDBC driver
doesn't allow stmt.execute("commit") but I think other JDBC drivers map such a
call to an inner .commit() call. 

Comment 5 Sebb 2007-04-30 15:37:14 UTC
(In reply to comment #3)
> Created an attachment (id=20036) [edit]
> add the possibility of issuing commit and rollback toward the database
> If you set autocommit to false, it becomes imposible to issue commit and
> rollback instructions at least to databases that doesn't support COMMIT and
> ROLLBACK as statements. Those database require you to use conn.commit() and
> conn.rollback() instead. With this patch you can write commit or rollback in 
a
> JDBC Request and the JDBC Sampler will translate it to the correct .commit() 
or
> rollback() call.

The patch assumes that a script starting with "commit" or "rollback" contains 
nothing else.

For databases that do allow commit and rollback statements this is 
unnecessarily restrictive.

I think a different approach is needed for databases that don't support these 
commands.
Comment 6 Sebb 2007-04-30 15:42:24 UTC
(In reply to comment #1)
> Created an attachment (id=20035) [edit]
> set auto-commit configuration parameter at the same level as pool-controller
> I've checked this and you are right. There is a bug on the
> DataSourceElement.java . The code tries to se the "auto-commit" attribute as
> part of pool-controller but auto-commit doesn't belong to pool-controller it
> should be a sibling of pool-controller. This becomes clear taking a look to 
the
> excalibur-datasource-1.1.1.jar source code 
ResourceLimitingJdbcDataSource.java
> , more precisely the lines
> *** final Configuration controller = configuration.getChild( "pool-
controller"
> );
> *** final boolean autoCommit = configuration.getChild( "auto-commit"
> ).getValueAsBoolean( true );
> Looking at those lines is evident that pool-controller and auto-commit are
> siblings and auto-commit shouldn't be added as a child of pool-controller
> I'm providing a patch attached that solves the issue.

OK, applied in r533871
Comment 7 Sebb 2007-05-02 16:36:25 UTC
I've added some new JDBC Sampler types: commit, rollback and autocommit 
on/off. These are in SVN r534651.