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.

Signature
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
joeNOSPAM@BEA.com - 25 May 2007 23:02 GMT
> 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
[quoted text clipped - 37 lines]
> gor...@panix.com 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
Alfred - 27 May 2007 06:55 GMT
> ...
> Hi, yes. Look at the Statement addBatch() and executeBatch() calls.
>
> Joe Weinstein at BEA Systems
To OP: And use PreparedStatement for operations like this
because on server side it will be a precompiled procedure
after creating.
Alfred