Re: Thread or not threads? - Mailing list pgsql-general

From per@nospam.mimer.se (Per Schröder)
Subject Re: Thread or not threads?
Date
Msg-id Xns9095B4A108CF8pescatmimer@192.71.97.199
Whole thread Raw
List pgsql-general
>
>Raymond Chui <raymond.chui@noaa.gov> wrote:

>> 2) Use batched update. Requires a JDBC 2 compliant driver.
>> The purpose is to reduce the number of server roundtrips.

>What is batched update?

PreparedStatement.addBatch() and PreparedStatement.executeBatch().

Something like this:


PreparedStatement ps = con.prepareStatement("INSERT INTO XX VALUES
(?,?,?)");


//later...
for (int i=0; i<100 /*maybe?*/; i++) {
   // Get data
   ps.setInt(1,ival);
   ps.setString(2,sval);
   ps.setFloat(3,fval);
   ps.addBatch();     // Add one record to the batch
}

// Note! nothing sent to server yet.
int sv[] = ps.executeBatch();
// Now, 100 lines are inserted in one go!
con.commit();
// Commit 100 lines



/Per Schr�der
http://developer.mimer.com

pgsql-general by date:

Previous
From: "Clay & Judi Kinney"
Date:
Subject: Newbie Question
Next
From: Stuart
Date:
Subject: datetime arithmatic