You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by Martin Kalén <mk...@apache.org> on 2005/04/07 10:13:06 UTC
Make CommonRDBMSAdapter#revokePermission use re-usable PreparedStatements
Greetings,
as noted in my comment to bugzilla #34343 my previous patch
to fix CommonRDBMSAdapter#revokePermission only made the SQL
usable, not fully _re-usable_ as PreparedStatement.
A better approach is to use exactly the same technique as
the patch I filed in bugzilla for #34343, ie keep a statement
parameter ("?") in the SQL string and use JDBC setNull() if
the value is null.
In this way, the RDBMS can actually re-use the prepared statement
regardless of explicit revisionNumber or null-value. Previously
it was almost a waste of resources using prepared statement when
parts of the SQL were hardcoded anyway.
"SELECT * FROM TABLE WHERE A = ?" is reusable and the DB-server
only needs to parse/prepare it once for A = '1','2' etc.
"SELECT * FROM TABLE WHERE A = 1" and "SELECT * FROM TABLE WHERE A = 2"
are not interchangeably re-usable and needs to be parsed/prepared twice.
(In my second example it's actually better to use Statement instead
of PreparedStatement since there is no parameters and no chance of
re-use, thus we can skip any overhead for preparing the statement.)
I'm attaching a new unified patch for CommonRDBMSAdapter to implement
this, and also change the SQL to the syntax Tomasz Majchrzak used
for PostgreSQL. His syntax is IMO more readable and still works with
Oracle. Tested with Oracle9i.
Regards,
Martin