Re: Slow performance with SQL and stmt.executeUpdate()
- From: "joeNOSPAM@xxxxxxx" <joe.weinstein@xxxxxxxxx>
- Date: 25 May 2007 15:02:54 -0700
On May 25, 2:35 pm, John Gordon <gor...@xxxxxxxxx> wrote:
I have an application that writes to an Oracle SQL database. The main
loop reads one data record from an external source, splits it into
fields then writes it to a database table with a Statement.ExecuteUpdate
method call, using SQL insert.
The whole program is too big to post here, but this is the gist of it:
Connection conn = DriverManager.getConnection(...);
Statement stmt = conn.createStatement();
while(externalSourceHasData)
{
MyData md = readRecordFromExternalSource();
String name = md.getName();
String phone = md.getPhone();
String address = md.getAddress();
stmt.executeUpdate("insert into mytable values ('" + name +
"','" + phone + "','" + address + "')");
}
conn.close();
Performace is somewhat of an issue. It's marginally acceptable, but would
be nice if it were faster. Is there anything obvious that I'm doing wrong
here?
One thing I considered was turning off auto-commit, then doing a commit
after the loop is finished. Would this make a noticable difference on
200k records?
Also, is there a way to write more than one record at a time? Some sort
of batch-writing capability?
Thanks for any suggestions.
--
John Gordon A is for Amy, who fell down the stairs
gor...@xxxxxxxxx B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
Hi, yes. Look at the Statement addBatch() and executeBatch() calls.
Joe Weinstein at BEA Systems
.
- Follow-Ups:
- References:
- Slow performance with SQL and stmt.executeUpdate()
- From: John Gordon
- Slow performance with SQL and stmt.executeUpdate()
- Prev by Date: Slow performance with SQL and stmt.executeUpdate()
- Next by Date: Re: JDBC: Fast way to find the number of rows in a ResultSet?
- Previous by thread: Slow performance with SQL and stmt.executeUpdate()
- Next by thread: Re: Slow performance with SQL and stmt.executeUpdate()
- Index(es):
Relevant Pages
|
|