commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject [DbUtils] RE: Batch Update
Date Tue, 02 Mar 2004 16:13:35 GMT

Hi,
Ooh, it's been a little while since I've seen a 2d array parameter ;)
Anyways, I don't have a response as I haven't been involved with DbUtils
for a little bit, but I wanted to ask that you prepend your subject
lines with the name of the component in question, e.g. [DbUtils] Batch
Update ;)

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Adkins Kendall [mailto:Kendall.Adkins@HCAhealthcare.com]
>Sent: Tuesday, March 02, 2004 10:11 AM
>To: 'commons-dev@jakarta.apache.org'
>Subject: Batch Update
>
>Has any consideration been given to adding batch update capability?
For
>instance, the following method could be added to the QueryRunner class:
>
>/**
> * Execute a batch of SQL INSERT, UPDATE, or DELETE queries.
> *
> * @param conn The connection to use to run the query.
> * @param sql The SQL to execute.
> * @param params An array of query replacement parameters.
> * @return The number of rows updated per statement.
> * @throws SQLException
> */
>public int[] batchUpdate(Connection conn, String sql, Object[][]
params)
>	throws SQLException {
>	PreparedStatement stmt = null;
>	int[] rows = null;
>	try {
>		stmt = this.prepareStatement(conn, sql);
>
>		for(int i = 0; i < params.length; i++) {
>			this.fillStatement(stmt, params[i]);
>			stmt.addBatch();
>		}
>		rows = stmt.executeBatch();
>	} catch (SQLException e) {
>		this.rethrow(e, sql, params);
>	} finally {
>		DbUtils.close(stmt);
>	}
>	return rows;
>}
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org




This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message