Slow performance with SQL and stmt.executeUpdate()



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
gordon@xxxxxxxxx B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

.



Relevant Pages

  • Need help with string splitter.
    ... I'm working on a program which splits a long string into a series of ... You enter a string into variable "str" ... occupied segment of the array, ... I think it might be a problem with the While loop, ...
    (comp.lang.cpp)
  • Split a string, but ignore quoted spaces
    ... Now I want to write a shell script that processes each of these quoted ... that's very easy with a for loop: ... this splits the string by *all* spaces contained - the ...
    (comp.unix.shell)
  • extension_pack
    ... It is used to set upper loop -- limits for non-deterministic values thus avoiding the use of access -- types and enabling the functions to be used for synthesizeable code. ... DivisorVal: integer) return std_logic_vector; function "/"(DividendVal: string; DivisorVal: integer) return std_logic_vector; ... for loopVar in 0 to slvVal'length/4-1 loop ... end loop; if then return not resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to else return resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to end if; ...
    (comp.lang.vhdl)
  • extension_pack
    ... It is used to set upper loop -- limits for non-deterministic values thus avoiding the use of access -- types and enabling the functions to be used for synthesizeable code. ... DivisorVal: integer) return std_logic_vector; function "/"(DividendVal: string; DivisorVal: integer) return std_logic_vector; ... for loopVar in 0 to slvVal'length/4-1 loop ... end loop; if then return not resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to else return resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to end if; ...
    (comp.lang.vhdl)
  • extension_pack
    ... It is used to set upper loop -- limits for non-deterministic values thus avoiding the use of access -- types and enabling the functions to be used for synthesizeable code. ... DivisorVal: integer) return std_logic_vector; function "/"(DividendVal: string; DivisorVal: integer) return std_logic_vector; ... for loopVar in 0 to slvVal'length/4-1 loop ... end loop; if then return not resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to else return resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to end if; ...
    (comp.lang.vhdl)