java - Execute Batch with only one query? -
my general question is: inefficient/bad practice call preparedstatement.executebatch() if there's 1 query in batch?
i'm writing generic method java helper library execute query. there's javabean called helperquery holds list of arrays javabean called queryparameter holds type (like string, blob, int, etc.) , value. queryparameter used fill helperquery's preparedstatement. in many cases, there 1 array of queryparameters.
my specific question is: should handle things differently if there's 1 array of queryparameters or ok handle things same regardless of how many queryparameters there are?
executebatch "super" method preparedstatement's parent statement returns int[] indicates success/failure of executed queries , executequery returns resultset. therefore, idea have 2 totally different method calls developer can handle them differently. recommend:
- an
executequery(helperquery helperquery)method return associatedresultset, firstqueryparametershelperquery(for convenience) , method developer can specifyqueryparameterset use (either have them specify number ofqueryparameterlist or pass inqueryparameters explicitly (i recommend second of two)). - an
executebatch(helperquery helperquerymethod returnint[], developer can handle wish.
it's give user (developer in case) power want (but provide simple solution them perform common tasks).
Comments
Post a Comment